Skip to content

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

Turso 8 min read Opinion mediumAdept

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

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.

Related posts

  • Multi-tenancy at Scale: How to Give Every User Their Own Database

    Turso mediumAdept

    The standard warning against database-per-tenant assumes each database is a server process like PostgreSQL or MySQL, with its own memory, connection pool and backup schedule. When a database is a SQLite file, an idle tenant costs only storage, so 1,000 tenant databases fit in a ~$25/month Turso plan instead of five figures on RDS. Per-tenant databases replace Row-Level Security and `tenant_id` filtering with routing to the right database. That makes isolation, BYOK encryption, regional data residency and GDPR deletion architectural properties. The costs are harder cross-tenant analytics, coordinated schema migrations across the fleet, and a poor fit for consumer apps with millions of tiny users or products needing constant cross-tenant queries.

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

  • Multi-Tenant E-Commerce Architecture with Turso

    Turso mediumAdept

    A multi-tenant storefront architecture that shares one template codebase but gives each store its own Vercel project, environment variables (name, theme, Stripe key) and Turso database, avoiding shared-database tenant isolation. New stores are provisioned by creating a Vercel project and a database seeded from a template database (or kept in sync via Turso Multi-DB Schemas), with the database URL derived from the project's production URL so queries need no tenant filter. The tradeoff favors strong isolation, simpler debugging and per-store cost attribution over the overhead of many deployments and databases.

  • Databases as Variables: What Unlimited Databases Actually Changes

    Turso mediumAdept

    Turso Cloud's paid plans no longer meter active databases, so a database costs only its storage while idle. That changes the cost math behind choosing a shared tenant_id schema. Because a Turso database is a file stored as 128 kB segments in object storage with copy-on-write branching, per-tenant, per-agent-session, per-experiment, per-regulated-user and per-PR databases become cheap, and provisioning takes two Platform API calls seeded from a template. Real costs remain: cross-tenant analytics pipelines (CDC helps), fleet-wide migration runners, routing and monitoring, so shared schemas still suit early, unregulated or analytics-heavy products, and a hybrid is often best.

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

    Neon mediumAdept

    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.

The quest for software engineering knowledge.

Look:
Layout: