DBPedias

All your database knowledge are belong to you

MySQL

Replication - Daisy Chaining Setup

Strengths of Daisy Chaining:

  • Easy to set up.
  • Able to better withstand the death of a master.
  • Easy to add slaves to the setup without stopping the master.

Weaknesses:

  • Death of a slave can bring down one or more slaves.
  • Slaves farther down the chain can lag very far behind the master.
  • Master and Slaves should be on equivalent quality hosts.
  • Makes using replication for backup difficult.

Recommended Environment:

  • OLTP application with a very high uptime requirement.
  • OLTP application with no room for loosing data.
RPDC 64.gif

For a system that needs to withstand the loss of one or more machines and still remain up, a daisy chain setup makes good sense. If server 10 in the diagram above fails, then the application can quickly be pointed to server 11. When server 10 is rebuilt it can be slid onto the end of the chain without stopping the application. This is true because the dead server 10 can be set up from a consistent copy on server 12 without affecting machines above it in the chain.

The trouble here lies in the notion that if the application is written to leverage slaves for reads and slave 11 dies, then slaves 12 and 13 are also effectively dead. However, this is really only an issue if the top level slave (11) goes down because any other slave can be rebuilt from the slave above it.

The other issue is stopping a slave for getting a consistent backup. By stopping any but the topmost slave (11), the risk is that there is a delay in replication and the backup is too old. By stopping the top slave, the risk is that subsequent slaves down the chain never catch up. For this reason, it is better to use a hybrid of the daisy chain and Master - Slave - Slave setup in the diagram below.

RPDC 65.gif

The slave array on the left provides all the benefits of the daisy chain for failover and keeping the replication array robust while the single slave (12) provides the ability to stop and start a slave for getting consistent backups.

This notation of a hybrid can also be used to hang several chains off the master so that the likelihood of the top level slave failing is very low.