Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Neon 8 min read Opinion mediumAdept

Database-per-User Architecture With Shared Application Environments: How and Why

A single shared application environment serving many per-customer Neon Postgres databases keeps deployment simple, but every tenant database must stay at the same schema version and data residency is hard to offer. Tenant identification can come from a login field, a per-customer subdomain, or a lookup from the user's credentials. A catalog database maps users or JWT-carried customer IDs to Neon project IDs for connection routing, and it also holds tier and feature-flag context. Schema changes need either slow, backward-compatible rollouts using views and triggers, or pre-upgrade testing of each tenant database on branches. The control plane should be kept separate from the app so failures don't take both down.

Assumes: multi-tenant SaaS basicsPostgreSQL schemasJWT authentication

Related posts

  • Database-per-User Architecture With Isolated Application Environments

    Neon mediumAdept

    Deploying a full copy of the application and its own Neon Postgres project per customer is justified mainly by data residency requirements and by letting customers control upgrade timing, not by per-customer customization, which turns each deployment into a separate product. Complexity moves from runtime routing into provisioning, a central control plane and catalog database that track feature enablement and deployed versions, and per-customer networking such as subdomains or custom URLs. The hardest part is versioning: when fixes are backported across release series, upgrades should be linearized through each minor series, and schema migrations should be idempotent (checking for existing columns and constraints) so backported changes don't conflict with later upgrades.

  • Multi-tenancy and Database-per-User Design in Postgres

    Neon easyNovice

    Postgres multi-tenancy comes in three main designs: shared schema, schema-per-user and database-per-user. Shared schema is cheapest but raises the risk and impact of isolation failures. Schema-per-user adds operational burden without strong isolation and is rarely worth it today. Database-per-user gives full isolation, data residency control and a fix for noisy neighbors, and it can pair with either isolated or shared application environments, each with tradeoffs in onboarding, versioning and complexity. Running it at scale requires a control plane to automate onboarding, monitoring and schema upgrades across the database fleet.

  • Control Planes for Database-Per-User in Neon

    Neon mediumAdept

    A database-per-user architecture on Neon usually means one Neon project per customer, and that quickly needs a control plane to manage onboarding, monitoring and schema upgrades across many projects. The core piece is a catalog database: a separate Neon project holding an account manifest, per-project metadata such as deployed schema version, and billing data. It should use foreign keys, citext/uuid/timestamptz types and indexes. The practical advice is to start with the Neon console, neonctl and runbooks, automate the most time-consuming tasks first, and treat the control plane as an internal product. Tracking each database's migration version through tools like sqitch or Flyway is critical for rolling out upgrades safely.

  • 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.

  • The Many-Database Architecture: Should You Give Every Tenant Their Own Database?

    Turso mediumAdept

    Shared schema with row-level security, schema per tenant, and database per tenant trade off isolation strength against operational cost. Shared schema stays simplest for many small tenants and cross-tenant analytics, but its isolation is only logical. Schema-per-tenant takes on most of the overhead of separate databases for only part of the isolation. Database-per-tenant gives structural isolation, trivial per-tenant deletion and placement in a chosen region. Cheap SQLite-based databases make it affordable, though routing, monitoring and cross-tenant analytics (via ETL or CDC) become operational work. A TypeScript example shows provisioning from a template database and scoping tokens per tenant.

The quest for software engineering knowledge.

Look:
Layout: