Nội dung text 06 - Database Scaling.pdf
Database Scaling Techniques
Replication SYNC/ ASYNC Changes on one database ( Master) needs > Replication to be sent to Replica to maintain consistency Master Replica Two modes of replication 1. Synchronous replication - strong consistency w > < w > API < " > < - zero replication lag Master Replica - slower writes 2. Asynchronous replication - eventual consistency ◦ w > API w > > - some ± replication lag < a s - faster writes Master Replica Horizontal Scaling : Stranding Because one node cannot handle the data / load we split it into multiple exclusive subsets writes on a particular crow / document will go to one particular shard .
This way, we scale our overall database load shard shard 2 Note:shards are independent I no replication by them API < > API server needs to know whom > shards to connect to, to get things done. Note:some databases has a proxy that takes care of routing Each shard can have its own replica (ifneeded ( Exercise 1. configure one Mysal as replica of another 2. Put some data and see the replication happening 3.write a small APIservice thathas two connection obj 4 one master and one replica 3. depending on the request, make call to either master on replica 5. implementsharding by spinning Two DB 4 one handling keys (atom) ↳ second handling keys (mtoz) 6. While APIservice thatroutes requestto one of them depending on key