Database Scaling
Scale read
- Database sharding
- However sharding is very hard and complex to get it right which create hotspot problem
- Database Read replica pattern
- Caching
- Indexing
- Note: do not create an index when the column has a lot of updates or the column has a lot of data, which is very costly to rebalance
Scale write
- Database sharding
- Use CockroachDB which supports horizontal scaling in RDBS
- Master-master or multi-master
- If ACID is not required, BASE can be used to do NoSQL
- Can scale much better because it splits into multiple nodes (shard) by default
- Does all the auto-scaling behind the scenes without the need to set up, we can add more nodes
- Terms/Request Coalescing
Connection pooling
- Use the connection pool to reuse connection
- use RDS proxy if cloud