Copying data to multiple servers Day 122 of 149 π Full deep-dive with code examples The Backup Copy Analogy Important documents: One copy at home One copy at the bank One copy at your lawyer's If your house burns down, you still have copies! Database Replication keeps copies of your database in multiple places! Why Replicate? Safety: If one server fails, another replica may still have the data (and can take over, depending on your setup) Can reduce data-loss risk, but replication is not a full backup strategy by itself Speed: Users far away can read from a nearby replica Can reduce read latency for globally distributed users Availability: One server down β Others handle requests Less downtime for users (depending on failover and client behavior) Types of Replication Primary-Replica: Primary (writes) βββ Replica 1 (reads) ββββ Replica 2 (reads) Enter fullscreen mode Exit fullscreen mode One leader accepts writes Replicas get copies, handle reads Multi-Primary: Multiple servers accept writes More complex,β¦