Complete Guide to Serverless Databases
Choose and operate serverless databases for event-driven apps: DynamoDB, Aurora Serverless, FaunaDB, PlanetScale — pricing, scaling, and trade-offs.
Introduction
Serverless applications need serverless databases. Traditional databases require provisioning, connection management, and capacity planning : all things the serverless model was designed to eliminate. Mismatched pairs hurt twice: a Lambda function that scales to a thousand concurrent executions will happily knock over a Postgres instance sized for fifty connections.
A serverless database isn’t just “a database someone else runs” — it’s a database that scales to zero when idle, scales up with your traffic, bills per use, and manages connections for workloads that appear and disappear in milliseconds. This guide compares the four that matter most (DynamoDB, Aurora Serverless v2, FaunaDB, and PlanetScale), then covers the parts the marketing pages skip: connection pooling, cold starts, data modeling, and when a serverless database is the wrong choice entirely.
Quick answers
- Need extreme scale and simple key-based access on AWS? DynamoDB.
- Need real SQL with serverless billing on AWS? Aurora Serverless v2.
- Need global distribution with strong consistency? FaunaDB.
- On MySQL and want branching workflows? PlanetScale.
- Steady, predictable load? Skip all four; provisioned is cheaper.
Serverless vs Managed vs Self-Hosted
The terms get used interchangeably and they aren’t the same thing:
- Self-hosted — you run the database on your VMs, manage patches, backups, failover, and capacity. Maximum control, maximum work.
- Managed — a provider runs the database for you (RDS, Cloud SQL, Atlas) but you still pick instance sizes, pay for provisioned capacity whether you use it or not, and manage connections yourself.
- Serverless — you pay per use, the database scales to zero when idle, scales with load automatically, and ideally removes the connection problem entirely (HTTP APIs) or manages it for you (RDS Proxy, Vitess drivers).
A managed Postgres instance isn’t serverless just because someone else patches it — it still bills for idle time and still has a connection ceiling. The test for “serverless” is whether the billing and the capacity both follow your actual usage instead of a provisioned floor.
The Two Families of Serverless Databases
“Serverless database” covers two different families, and confusing them is the first mistake:
- NoSQL/document stores (DynamoDB, FaunaDB) — HTTP API, no connections to manage, scale to infinity, but force you to model data around access patterns instead of relations.
- Serverless relational (Aurora Serverless, PlanetScale) — real SQL, familiar modeling, but connections still exist underneath — which is where pooling becomes the problem to solve.
| DynamoDB | Aurora Serverless v2 | FaunaDB | PlanetScale | |
|---|---|---|---|---|
| Model | Key-value/document | Relational (MySQL/Postgres) | Document-relational | Relational (MySQL/Vitess) |
| Access | HTTP API (IAM) | TCP connections | HTTP API (FQL/GraphQL) | TCP + serverless driver (HTTP) |
| Scale-to-zero | Yes (on-demand) | Yes (0 ACU minimum optional) | Yes | No (KS replicas) |
| Pricing | Per request + storage | Per ACU-hour | Per operation | Per row read/written |
| Best for | Extreme scale, simple access | Existing SQL apps on AWS | Global distribution | MySQL teams, branching workflows |
The rest of this guide walks through each one, then the operational realities.
Amazon DynamoDB
DynamoDB is the default serverless database on AWS. Fully managed, scales to millions of requests per second, bills per request (on-demand mode) or per provisioned capacity. Single-digit-millisecond latency at any scale, no connections to manage because access is over HTTP with IAM auth.
import { DynamoDBClient, PutItemCommand } from '@aws-sdk/client-dynamodb';
const client = new DynamoDBClient({});
await client.send(new PutItemCommand({
TableName: 'orders',
Item: {
pk: { S: 'order#123' },
sk: { S: 'order#123' },
total: { N: '99.50' },
},
}));
The catch is the data model: DynamoDB is a key-value store, not a relational database. You design around access patterns (partition key + sort key, GSIs for secondary queries), not around tables and joins. Teams that treat it like Postgres end up with scans that cost money and latency. It also charges for every read/write unit. Spiky workloads are cheap, but hot partitions and unplanned scans get expensive fast.
Choose DynamoDB when: extreme scale, predictable access patterns, AWS-native stack, and you can design the keys upfront. Avoid it when your queries are exploratory or relational at heart.
Aurora Serverless v2
Aurora Serverless scales real Postgres or MySQL in ACU (Aurora Capacity Unit) increments. It looks and acts like the relational database you already know, but capacity adjusts to load in near real time, down to 0.5 ACU (or zero, with auto-pause).
// Standard pg client — Aurora Serverless speaks normal Postgres
import pg from 'pg';
const client = new pg.Client({ host: process.env.AURORA_ENDPOINT, /* ... */ });
await client.query('SELECT * FROM orders WHERE user_id = $1', [userId]);
The appeal: keep your SQL, your ORM, your joins, your existing schema, and stop paying for idle capacity. The catches: connections still exist (a thousand concurrent Lambdas can still exhaust them, hence RDS Proxy below), scale events are fast but not instant (capacity ramps in seconds, so a hard traffic spike can outrun it), and minimum-ACU billing means scale-to-zero costs extra or requires the auto-pause variant.
Choose it when you have an existing relational app on AWS and want serverless billing without a rewrite. Avoid it if you need instant zero-to-thousand scaling or your workload is steady enough that provisioned is cheaper.
FaunaDB
FaunaDB is a document-relational database built for global distribution: multi-region active-active by default, transactions that work across regions, and both document and relational modeling in one. Access is over HTTPS (FQL or GraphQL), so there are no connections to manage and cold-start Lambda functions aren’t a problem.
The trade-offs: FQL is a proprietary query language (your queries don’t port elsewhere), pricing is per-operation and gets opaque at scale, and the ecosystem is smaller: fewer tools, fewer ORMs, fewer Stack Overflow answers. FaunaDB shines for globally distributed apps that need strong consistency and can accept vendor lock-in; it’s a harder sell for a standard CRUD app that could live in Postgres.
PlanetScale
PlanetScale is serverless MySQL built on Vitess (the tech that scaled YouTube’s MySQL): real relational semantics with a genuinely different operational model. Its two killer features:
- Database branching — Git-style branches for your schema: develop on a branch, merge with a deploy request, schema changes roll out non-blocking.
- Serverless driver — connects over HTTP, eliminating the TCP connection limit that kills Lambda-Postgres setups.
import { connect } from '@planetscale/database';
const conn = connect({ url: process.env.DATABASE_URL });
const rows = await conn.execute('SELECT * FROM orders WHERE user_id = ?', [userId]);
Pricing is per row read/written (scaler tiers exist), which is friendly for typical apps but needs modeling at scale. Limitations: no scale-to-zero on the base tier, foreign key constraints aren’t supported (Vitess constraint — enforce referential integrity in app code), and some MySQL features (stored procedures, triggers) are unavailable. The right pick for MySQL teams that want serverless ergonomics and modern schema workflows; wrong if you need strict foreign keys or Postgres extensions.
Choosing a Serverless Database
The decision tree collapses to three questions:
The heuristics that actually decide it:
- Access pattern predictability: DynamoDB rewards known queries; if you can’t list your access patterns upfront, a relational option saves you a redesign.
- Connection architecture: HTTP-API databases (DynamoDB, FaunaDB, PlanetScale’s driver) are immune to the Lambda connection problem; TCP ones (Aurora) need pooling.
- Ecosystem and lock-in: DynamoDB and Aurora keep you in AWS’s gravity well; PlanetScale’s branching and FaunaDB’s model are sticky in different ways.
Consistency, Multi-Region, and Backups
Three operational dimensions the brochures blur:
- Consistency — DynamoDB reads are eventually consistent by default (strong consistency costs double); Aurora Serverless is fully ACID like its provisioned sibling; FaunaDB is strictly serializable everywhere; PlanetScale is MySQL-consistent within its Vitess limits. “Serverless” says nothing about consistency; check per product.
- Multi-region — DynamoDB Global Tables and FaunaDB replicate actively across regions out of the box; Aurora Serverless doesn’t do active-active (Aurora Global Database exists but is provisioned); PlanetScale replicates, but the writer is single-region. If your app is multi-region, this one constraint eliminates half the list.
- Backups — all four offer point-in-time recovery, but verify the retention window and restore mechanics before you need them; “managed” doesn’t mean “you tested a restore”.
The Real Cost Math
Serverless database pricing is per-use, and the honest comparison requires your own numbers:
- DynamoDB — ~$1.25 per million writes, ~$0.25 per million reads (on-demand), plus storage; cheap at low and spiky load, expensive if you scan or your requests are large.
- Aurora Serverless —
$0.12 per ACU-hour, minimum 0.5 ACU when running ($44/month floor) unless you use auto-pause to zero. Storage and I/O billed separately and often dominate the bill. - FaunaDB — per-read/write-operation; transparent at small scale, harder to forecast once queries get complex.
- PlanetScale — per billion rows read/written tiers; the mental model is closest to “pay per query volume” — good for typical CRUD, needs monitoring for analytic-style reads.
The comparison to run: provisioned instance cost (instance + storage + your ops time) versus projected per-use cost on your actual query profile. Serverless wins on idle time and variance; provisioned wins on sustained utilization — there’s no universal cheaper option, only a cheaper option for your shape of traffic.
Data Modeling for Serverless
Modeling differs radically by family:
- DynamoDB — design the keys first: partition key distributes load, sort key powers queries, GSIs handle secondary patterns. Single-table design (one table, entity types distinguished by key prefixes) is the dominant pattern — trading normalization for access-pattern efficiency.
- Relational serverless — model as normal, with two additions: foreign keys may not exist (PlanetScale), and queries that were “fine” at 100 connections can blow up when a thousand Lambdas run them concurrently. Denormalize hot read paths where the alternative is a join under concurrency.
Either way, the discipline is the same: in serverless, the query patterns are the schema. Design them before the tables.
Connection Management and Cold Starts
The operational issue nobody warns you about: a Lambda function that scales to 1,000 concurrent executions opens up to 1,000 database connections. Relational databases weren’t built for that — a Postgres box taps out at a few hundred.
The fixes, in order of preference:
- Use an HTTP-API database — DynamoDB, FaunaDB, PlanetScale’s driver, Aurora’s Data API. No connections, no problem. This is why these exist.
- Connection pooling proxy — RDS Proxy for Aurora, PgBouncer-equivalent for others. The proxy multiplexes thousands of app connections onto a small pool of database connections (see the connection pooling pattern).
- Reuse connections across invocations — initialize the client outside the Lambda handler so it persists across warm invocations; never open a connection inside the handler per request.
The companion cold-start issue: database connections take time to establish (TCP + TLS + auth), and a fresh Lambda adds that to every cold start. HTTP APIs and warm-connection reuse eliminate most of it; RDS Proxy adds a small fixed cost in exchange for the pooling.
A Worked Example: The Same App on Two Databases
The fastest way to feel the difference is the same service implemented twice. Take an order service that needs to fetch a user’s orders — on DynamoDB versus Aurora Serverless.
On DynamoDB, the schema is designed around that query upfront:
// Table: pk=user#<id>, sk=order#<date>
// Fetching a user's orders is a Query on the partition key
const orders = await client.send(new QueryCommand({
TableName: 'orders',
KeyConditionExpression: 'pk = :pk AND begins_with(sk, :prefix)',
ExpressionAttributeValues: {
':pk': { S: `user#${userId}` },
':prefix': { S: 'order#' },
},
}));
One request, one partition read, single-digit milliseconds, no connection. But the query was only possible because someone designed pk/sk for it at table-creation time. “Show me orders by status” needs a GSI; “join orders to products” doesn’t exist at all — you denormalize or do it in application code.
On Aurora Serverless, the same query is the SQL you already know:
const { rows } = await client.query(
'SELECT * FROM orders WHERE user_id = $1 ORDER BY created_at DESC',
[userId]
);
No upfront design, joins available, indexes handle new query shapes — but the connection that query runs on had to come from somewhere: RDS Proxy or a warm Lambda, and at 1,000 concurrent executions it’s the bottleneck the whole section above exists to solve.
Neither is “better” — they’re different contracts. DynamoDB trades flexibility for scale and zero connection management; Aurora keeps the flexibility and makes you solve the connection problem.
Monitoring and Observability
Serverless billing makes monitoring a cost discipline, not just a reliability one:
- DynamoDB — watch
ConsumedReadCapacityUnits/ConsumedWriteCapacityUnitsper table and per GSI; a runaway Scan shows up as a capacity spike before appearing as a latency problem.ThrottledRequestsmeans your keys are hot-partitioned. - Aurora Serverless —
ServerlessDatabaseCapacitytells you what you’re paying for right now; correlate it withDatabaseConnectionsto see whether pooling is actually working (a flat high connection count means the proxy isn’t engaged). - Any manager — log the query that produced each operation. Per-request pricing means a chatty
SELECT *in a hot loop is a line item, not just a slow query.
The rule: in provisioned databases, a bad query costs latency; in serverless ones, it costs latency and money. Alert on both.
When Serverless Databases Don’t Fit
The cases where a serverless database costs more than it saves:
- Steady, predictable load — a database that runs at 60% capacity 24/7 is cheaper provisioned than billed per request/ACU. Serverless pricing rewards variance.
- Heavy relational work — complex joins, aggregations, reporting: serverless NoSQL can’t do them, and serverless relational can hit ACU ceilings doing them at scale. A provisioned cluster with read replicas is often the honest answer.
- Data sovereignty/compliance — managed serverless offerings have region and residency limits that may not fit your constraints.
- Existing investment — a well-tuned provisioned cluster you already operate isn’t something to migrate for the label. The case for serverless is operational overhead and variable load, not fashion.
Serverless Databases Beyond AWS
AWS dominates the examples here, but the other clouds have their own entries worth knowing: Azure Cosmos DB is the closest DynamoDB analog: multi-model, globally distributed, billed per request unit; Google Firestore is document-oriented with strong mobile SDKs (the default for Firebase apps); GCP AlloyDB/Cloud SQL with serverless tiers cover the relational side. The selection logic from this guide still applies — consistency model, connection architecture, pricing shape — but note that multi-cloud portability is mostly a myth at the database layer; pick the one that fits your cloud gravity.
A Note on Vendor Lock-in
Every serverless database trades portability for convenience, and the degree matters:
- DynamoDB — the data model (pk/sk, single-table design) is the deepest form of lock-in: your schema decisions are DynamoDB-specific even before counting the API.
- Aurora Serverless — real Postgres/MySQL underneath, so schema and queries port; what you lose is the serverless behavior itself.
- PlanetScale — MySQL-compatible, ports with the foreign-key caveat; Vitess is open source, which softens the landing.
- FaunaDB — FQL is proprietary; migrating means rewriting queries, not just moving data.
The honest posture: accept the lock-in consciously when the operational savings justify it — and keep the parts that are portable (your data export paths, your access patterns documented) cheap to reconstruct elsewhere.
Production Checklist
Before a serverless database goes live, run through this list:
- Access patterns documented — every query the app makes is known and designed-for (critical in DynamoDB; a nice-to-have in relational).
- Connection plan — HTTP API or RDS Proxy in place; the 1,000-Lambda scenario is solved on paper before it happens in production.
- Cold-start budget measured — first request after idle takes how long? Connection establishment adds how much?
- Per-operation cost projected — your top three queries at your real traffic volume, priced out monthly.
- Backup restore tested — an actual restore, run once, timed.
- Rotation plan — credentials rotate without a deploy (managed identity, secrets manager, short-lived tokens).
- Alerting on capacity — consumed units / ACUs / operations per second, not just latency.
- Multi-region story decided — active-active needed or single-region acceptable; failover tested if the former.
Teams that skip the list discover it in production anyway — the difference is whether you learn it at 2pm in a test or at 2am in an incident.
Best Practices
- Model the access patterns first — especially in DynamoDB: the queries determine the keys, not the other way around.
- Cache aggressively — Redis/DAX in front of a per-request-billed database is a cost optimization, not just performance (caching strategies guide).
- Monitor per-operation cost — request pricing means inefficient queries cost money, not just time. Alert on consumed capacity, not just latency.
- Reuse connections on warm invocations — initialize clients outside the handler; it’s a one-line change with an outsized effect.
- Plan for the connection ceiling — if using TCP databases with Lambda, RDS Proxy isn’t optional at scale.
Common Mistakes
- Scans in DynamoDB — a Scan reads the whole table and bills accordingly; use Query with proper keys and GSIs.
- Ignoring cold-start connection cost — every fresh Lambda pays the TCP+auth tax; measure it and fix with HTTP APIs or pooling.
- Choosing serverless for the label — steady workloads pay more per-operation than a provisioned instance; do the math before migrating.
- Treating DynamoDB as relational — joins don’t exist; if your schema needs them, you chose the wrong database.
- Forgetting foreign keys on PlanetScale — referential integrity moves to your application code; missing it corrupts data silently.
See Also
- Amazon DynamoDB documentation — keys, GSIs, and the access-pattern design this guide references.
- Aurora Serverless v2 docs — ACU scaling and auto-pause.
- PlanetScale documentation — branching workflows and the serverless driver.
- Guides: complete-guide-serverless-architecture — the application architecture these databases sit under.
- Guides: complete-guide-aws-lambda-production — the compute side of the connection problem.
- Guides: complete-guide-redis-caching-strategies — the cache layer that makes per-request billing survivable.
- Patterns: serverless-db-connection-pooling-pattern — the pooling pattern for TCP databases.
- Companion resources — DynamoDB access-pattern design and the Lambda warm-connection pattern.
Frequently Asked Questions
What is a serverless database?
A database that scales to zero when idle, scales automatically with load, bills per use rather than per provisioned capacity, and handles connection management for ephemeral workloads. Examples: DynamoDB, Aurora Serverless v2, FaunaDB, PlanetScale.
DynamoDB or Aurora Serverless — which should I choose?
DynamoDB for extreme scale and simple key-based access on AWS-native stacks; Aurora Serverless when you need real SQL, joins, and existing relational schemas. The deciding factor is your access patterns: if they're predictable, DynamoDB's model is a strength; if they're exploratory or relational, Aurora is the honest choice.
Are serverless databases cheaper?
For variable or spiky workloads, yes: you pay per use and idle costs near zero. For steady high utilization, no; provisioned instances cost less per operation. Run the numbers on your actual load profile before migrating; serverless pricing rewards variance, not volume.
How do I handle database connections in serverless?
Prefer databases with HTTP APIs (DynamoDB, FaunaDB, PlanetScale driver, Aurora Data API) that eliminate connections entirely. For TCP databases, use a pooling proxy (RDS Proxy) and reuse connections across warm Lambda invocations by initializing clients outside the handler.
Can I use serverless databases for everything?
No. Heavy relational workloads, steady high-utilization loads, strict compliance requirements, and complex reporting are all cases where provisioned databases or traditional architectures fit better. Serverless databases are a tool for variable, event-driven workloads, not a universal upgrade.
What is the biggest DynamoDB mistake?
Using Scan instead of Query. A Scan reads every item in the table and bills for all of it. The fix is designing partition/sort keys and GSIs around your access patterns, which is also why DynamoDB demands upfront modeling that relational databases let you defer.
Related Resources
Complete Guide to Serverless Architecture
Decide when to go serverless and when not to. FaaS patterns, cold starts, cost models, vendor lock-in, and migration strategies for production.
GuideComplete Guide to AWS Lambda in Production
Run AWS Lambda in production: cold starts, deployment patterns, connection pooling, observability, security, retries and cost tuning with code.
GuideComplete Guide to Redis Caching Strategies
Choose and implement the right Redis caching pattern — cache-aside to refresh-ahead — with eviction, TTL, and production ops guidance.
PatternServerless DB Connection Pooling Pattern
Manage database connections across serverless invocations by using external connection poolers, connection reuse, and lightweight clients to avoid connection exhaustion.
GuideRead Replicas: Scale Reads Without Changing Your App
Production guide to database read replicas: streaming replication setup, read/write routing (app, ORM and proxy-based), replication lag handling, monitoring, failover and tuning for PostgreSQL, MySQL and cloud-managed replicas.
GuideComplete Guide to Database Sharding
Master database sharding: shard keys, partitioning strategies, consistent hashing, cross-shard queries, resharding, Vitess and Citus.