Rethinking read replicas for the lakebase architecture
Captured source
source ↗Rethinking read replicas for the lakebase architecture | Databricks Blog Skip to main content
Summary
In a traditional Postgres deployment, every read replica is a full clone of the primary, with its own instance and storage. That makes replicas slow to create, expensive to keep, and hard to use for scaling reads.
On the lakebase architecture, a read replica is just another compute on the storage the primary already uses. It's ready in seconds, adds no storage, autoscales with read load, and scales to zero when idle.
That turns replicas into a tool you can use per workload: for launches, dashboards, background jobs, read-only access for AI agents, and agents that add read capacity for their own tasks.
The idea behind read replicas makes sense: when your app gets busy, you add a couple of read-only replicas, route the heavy reads to them, and let the primary focus on writes. In practice, that rarely works well. In traditional managed Postgres, a replica is a physical clone of the primary: its own instance, its own storage volume, and its own copy of every page. That makes replicas impractical for scaling reads on the go. They take minutes to hours to create, each one adds a full copy of the data to your bill, and they keep running long after the traffic spike is gone. What was supposed to be a nimble way to scale reads turns into one more instance to manage.
A monolith replica copies the whole machine, disk included. A lakebase replica adds compute only, on top of one shared copy of the data
Like other DX problems with OLTP databases ,this is an architecture problem that comes from running things as a monolith. In Lakebase Postgres, a read replica doesn't copy anything - it's one more compute attached to the storage the primary already uses. It's ready in seconds, adds no storage, and scales to zero when nobody is reading from it. The traditional replica Replicas in Postgres are asked to do two jobs: standbys for high availability, and read replicas for scaling reads. This post is about the second one. (High availability replicas are also fascinating, and we'll cover how we approach HA in the lakebase architecture in a future post.) The case for read replicas Picture a typical Postgres deployment on a managed service like Amazon RDS. Postgres runs on a single instance, with its data on a storage volume attached to that instance. Backups and snapshots go to S3. Every query the app sends, reads and writes, lands on that one machine. Traffic keeps growing. Most of it is reads, and at some point the instance runs out of CPU and memory to serve them. On a monolithic service like RDS, you have two ways to scale: move to a bigger instance, or add a read replica and send some of the reads there. Deploying a replica is deploying a new instance On RDS, adding a read replica pretty much means building a second machine: RDS takes a snapshot of the primary instance It provisions a new instance from that snapshot, with its own compute and its own storage volume, and the volume has to be filled with the snapshot's data The primary keeps taking writes the whole time, so once the new instance is up, it uses Postgres streaming replication to catch up with every change made since the snapshot, and to keep up from then on Only then can you start routing reads to it
The work scales with the database. A bigger database means a bigger snapshot and a bigger volume to fill. A busier one means more WAL to replay before the replica catches up. On a small database, that can take minutes. On a large one, it can take hours. And "available" doesn't mean done. On RDS, the new replica's volume keeps loading data blocks from S3 in the background after the replica comes online, and AWS notes that performance might not be at its fullest until that finishes . The process isn't free for the primary either: creating the snapshot briefly pauses its I/O unless it runs Multi-AZ, and a long-running transaction on it slows the whole thing down. The problems you are left with Put all of that together, and you get a set of problems that share one root cause: in a monolith, the replica is a physical clone of the machine. Every replica duplicates the data: each replica you add copies the entire dataset, and you are billed for that storage. If the goal is read capacity, paying for a second copy of the data is pure overhead Replicas take time to be ready: since creating one takes minutes to hours, you cannot create a replica in response to a traffic spike. You have to guess the spike in advance and provision for it Replicas are always on: pausing and resuming a replica is a manual process, and a resumed replica has to catch up on all the WAL it missed while paused. So most teams don't bother: the replica runs 24/7, and you pay for its compute and storage 24/7 Replicas don't scale on their own: RDS, for example, does not autoscale read replicas. It won't add replicas when demand increases or remove them when it drops, and resizing a replica means resizing an instance
The result is the opposite of what replicas promised. Instead of an elastic way to scale reads, you get one more static, overprovisioned piece of infrastructure to maintain. So many teams do the rational thing: they oversize the primary for the peak and skip replicas altogether, or they keep one replica running full time, just in case. Rethinking read replicas in the lakebase The principle behind read replicas is sound. It's the monolithic implementation that broke them in practice. The lakebase architecture sets the stage for building replicas differently, making them much more usable: Replicas share the data: a replica is a compute attached to the same storage as the primary. Adding one copies nothing, so you pay for the compute it uses and nothing extra for storage Replicas are ready in seconds: there is no snapshot to take and no volume to fill, so creating a replica takes a few seconds however large the database is Replicas scale to zero: when nobody is reading from a replica, it suspends on its own and starts again on the next query, up to date with the primary almost immediately Replicas autoscale: each replica grows and shrinks its compute with read load, within the limits you set, so you size it for the traffic you have, not for the peak
It all starts with compute and storage being separate Services like RDS run Postgres as a monolith: a single machine that owns both execution and...
Excerpt shown — open the source for the full document.
Notability
notability 5.0/10Substantive Databricks engineering post on lakebase architecture.