Architecture: multi-region database
This course examines what a second region would require for a Rails application running on one VPS, with Postgres and uploaded files on the same disk. It covers the physics of cross-continent latency, four measurements to take before building anything, and why object storage and a CDN come first. It then explains read replicas in Rails, replication lag and read-your-own-writes, four consistency models alongside CAP and PACELC, and an ordered plan with a clear point to stop after each step.
What you'll learn
- ✓Finding every place an application stores state before replicating it
- ✓Measuring user RTT, round trips per page, database share and read/write ratio
- ✓Configuring a read replica in Rails and choosing which databases stay regional
- ✓Handling replication lag, read-your-own-writes and background job reads
- ✓Choosing a consistency model per operation, with CAP and PACELC in context
- ✓Ordering the work: object storage, CDN, edge cache, then a replica
One VPS, one region
Multi-region questions are easier to answer from a known starting point. Here is this application's, from config/deploy.yml.
Read the full lesson free →Curriculum
7 lessonsOne VPS, one region
Maps the single-VPS topology, finds uploads as the first blocker, and compares local and cross-continent round trips.
Measure before replicating
Four measurements to take before replicating, and why a CDN and edge caching usually come before a replica.
Read replicas
Configures a Rails read replica, decides which of four logical databases to replicate, and lists its costs.
The lag problem
Explains replication lag, read-your-own-writes failures, the delay window, LSN comparison and the background job case.
Consistency models
Compares strong, eventual, read-your-own-writes and monotonic consistency, clarifies CAP and PACELC, and chooses per operation.
What this application would do
Lays out an ordered plan from measuring to a regional app server, with a point to stop after each step.
Putting it together: three facts
Reviews the measured facts, the course's arguments and habits, and why this application mostly needs a CDN.