దశలవారీగా scale చేయండి: ముందుగా reads కోసం read replicas + caching, తర్వాత writes కోసం sharding (Vitess) — మరియు అన్నింటికంటే ముందు connection pooling ను జోడించండి, ఎందుకంటే అది చవకైన 10x. Reads మరియు writes వేర్వేరుగా scale అవుతాయి, కాబట్టి మొదటి రోజే sharding కోసం చేరుకోవద్దు.
┌─▶ Cache (Redis) ── hit ──▶ return
App ─▶ Pool(PgBouncer/ProxySQL) miss ▼
│ ┌─▶ Read replica 1 ┐
├──── reads ─────────┼─▶ Read replica 2 ┼─ (async replication)
│ └─▶ Read replica N ┘
└──── writes ──▶ Primary ──▶ (later) Vitess shards ─▶ Primary A / Primary B
Step 0: connection pooling
ప్రతి MySQL connection memory మరియు ఒక thread ను ఖర్చు చేస్తుంది. 100x traffic వద్ద మీరు CPU కంటే చాలా ముందే ను ఖాళీ చేస్తారు. లేదా వంటి ఒక pooler వేల app connections ను కొన్ని వందల DB connections పైకి multiplex చేస్తుంది. ఇది rearchitecture కాదు, ఒక config మార్పు — దీన్ని మొదట చేయండి.
