How to handle failover for wordpress woocommerce store?


Staff member
I am working on a project with multiple WordPress + Woocommerce stores. We have 3 dedicated servers. As the traffic grows. Sometimes, the server is down. I am looking for a failover solution that works with those wordpress+woocommerce sites.
First, I found CloudFlare. It will automatically failover to the other “A” record. So I just need to replicate all files and database to other server as backup. When the first server is down, it will point to another server.
But this comes with another problem. When it points to the second server. All the data in the database goes back to when the backup is created. And when the original server is fixed, the domain points back to the original server. Then all data written in second server is gone as it didn't write into the original server.
Then I looked into the master-slave replication of database. Assuming the original server is master and the second server is slave, each time when a customer bought a product or wrote a comment, it writes into the master database. Then the slave database sync the master database. But the problem is that when the original server is down. It switches to the slave database with is read-only. So even the customers could load the website. They could not make purchase or comment.
I have no idea what to do next. Please help. Thank you. We would like to archive the followings:
<li>switch servers when one is down</li>
<li>sync database anytime. No data loss during the switching process.</li>