Database Replication

Normally we have more read than write ratio. So the number of slave database is normally higher than master database

Pasted image 20220928183231.png

Advantages

  • Better performance: distribute read and write, allows queries to be processed parallely
  • Failover: if master dies, we promote a slave up to be master. There is no dataloss
  • High availability: even if the database is offline, you can still access the data in other databases
    • If a slave is offline, a new slave will be launch up to replace unhealthy slave
    • If master is offline, a slave is promoted to become master and a new slave is launched to replace it.