Multi-Tenant RAG With One Neon Project Per User
A multi-tenant RAG pipeline for a CRM isolates each organization's contacts and embeddings in a dedicated Neon Postgres project, created via the Neon API and looked up per workspace to build connection strings on the fly. Noisy-neighbor and cost risks from rate-limited SERP and OpenAI calls are handled with Inngest workflows keyed by workspace ID: enrichment is throttled to 10 executions per 10 seconds per workspace, and embeddings are batched up to 100 documents per workspace before insertion into that tenant's vector store. Code samples cover project provisioning, tenant connection lookup, and the throttle and batch configuration.
Related posts
- Neon for Agent Platforms: A Companion Skill for the AI Agent Program
Neon mediumAdept
neon-for-agent-platforms is an open-source companion Agent Skill and set of TypeScript scripts for running fleets of Neon Postgres databases on agent platforms. It covers a dual-org model that separates sponsored free-tier and paid customers, with one project per tenant transferred to the paid org on upgrade. It also covers copy-on-write dev and preview branches with shorter suspend timeouts to keep costs predictable, branch-based compound checkpoints, and the consumption API for per-customer cost attribution. Both skills install via npx, and the scripts can also be run directly against a Neon API key and org ID.
- Inside LuBot's database-per-tenant architecture
Neon mediumAdept
LuBot, a solo-founder analytics chat product, gives each paying customer an isolated Postgres database by creating a Neon branch from a Stripe webhook, with Supabase kept as the control plane for orgs, users and billing. Branches get deterministic names so webhook retries are idempotent; the new branch is migrated, its connection URL is stored on the user row, and all access goes through a single tenant resolver function. Tenant computes autoscale from 0.25 to 4 CU and suspend after 300 seconds idle, avoiding roughly $20/month per idle tenant. Behind PgBouncer transaction-mode pooling, session settings like search_path do not persist, so set them per query or at the role level, use direct URLs for migrations, and reset connections on check-in.
- Inside a Kylon room, where people and agents build apps on Neon
Neon easyNovice
Kylon, a shared workspace where teams and AI agents build internal apps like CRMs and invoice trackers, maps its product directly onto Neon resources: one Neon project per workspace, one database per app, and one branch per draft. Agents apply schema migrations and changes to a branch copy of real data, a person reviews the preview, and production changes only on publish. Scale-to-zero makes many mostly idle agent-built databases affordable. The Neon API, point-in-time restore and MCP let agents provision, manage and undo changes without anyone opening a console.
- The Noisy Neighbor Problem in Multitenant Architectures
Neon easyNovice
Noisy neighbors in a shared Postgres instance such as AWS RDS degrade performance for every tenant through CPU saturation, work_mem and shared_buffers pressure, disk I/O contention on EBS, exhaustion of max_connections, and lock contention from long transactions. Within RDS, the mitigations range from per-tier statement_timeout values, PgBouncer connection quotas per tenant and application-level rate limiting, to schema-per-tenant throttling, up to full database-per-tenant isolation, which is costly and operationally heavy. Neon's pitch is a project per tenant: storage is shared while each tenant gets isolated compute that autoscales and scales to zero, which makes per-tenant isolation affordable.
- Building an AI-powered ChatBot using Vercel, OpenAI, and Postgres
Neon mediumAdept
A ChatGPT-style documentation assistant (Ask Neon) is built by storing OpenAI text-embedding-ada-002 vectors in Postgres with pgvector, retrieving context by cosine distance, and feeding it to text-davinci-003 from a Vercel Edge Function. A window-function query caps retrieved context at a cumulative 1,500 tokens to fit the 4,096-token model limit, and an ivfflat index (lists ≈ 4·sqrt(rows)) speeds up the similarity search. Neon's WebSocket-based serverless driver works around Edge Functions' lack of TCP, and streaming completions via SSE parsing return answers faster. User feedback is stored for later fine-tuning.