システムの成長に伴い、データベースはしばしばボトルネックになります。スケーリングにはレプリケーション(読み取りスケーリングと可用性のためのコピー)、シャーディング(サーバー間でのデータ分割)、キャッシング、および適切なデータベースタイプの選択などのテクニックが含まれます。
レプリケーション — データのコピー
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)
