随着系统的增长,数据库通常成为瓶颈。扩展它们涉及复制(用于读取扩展和可用性的副本)、分片(跨服务器分割数据)、缓存和选择适当的数据库类型等技术。
Replication — 数据副本
REPLICATION → maintain COPIES of the database across servers:
→ PRIMARY (writes) + REPLICAS (copies):
- READ SCALING → direct reads to replicas (offload the primary) → handle more reads
- AVAILABILITY → a replica can take over if the primary fails (failover)
⚠️ replication lag → replicas may be slightly behind (eventual consistency for reads)
→ great for READ-heavy workloads and availability (most apps are read-heavy)
