One nice thing about Tungsten Clustering is that you need just a single command to move the master role to another host in your cluster. Using the cluster control tool (cctrl
) via the command-line, you just need to type "switch" to get the (complex) job done!
/alpha > switch
SELECTED SLAVE: host2@alpha
PURGE REMAINING ACTIVE SESSIONS ON CURRENT MASTER 'host1@alpha'
PURGED A TOTAL OF 0 ACTIVE SESSIONS ON MASTER 'host1@alpha'
FLUSH TRANSACTIONS ON CURRENT MASTER 'host1@alpha'
PUT THE NEW MASTER 'host2@alpha' ONLINE
PUT THE PRIOR MASTER 'host1@alpha' ONLINE AS A SLAVE
RECONFIGURING SLAVE 'host3@alpha' TO POINT TO NEW MASTER 'host2@alpha'
SWITCH TO 'host2@alpha' WAS SUCCESSFUL
What's even nicer is that in most cases, your application won't even notice that a master switch occurred. All you will get is a little lag in connectivity, while the new host is being reconfigured.
The magic resides in the fact that the connector is able to "pause" new connections during the switch operation:
- First, it will wait a configurable delay for ongoing connections to disconnect. After this delay, connections are forcibly closed (but they will generally try to reconnect by themselves)
- Then, any new connection request will be paused until the new master is ready to accept traffic. Here comes the little lag in your application!
- As soon as the new master is ready (usually within seconds), traffic continues, application's happy, so are your customers.
Of course, if your application was connected to a slave during the switch, the application will not even be affected by the switch!
Comments
Add new comment