Mysql – How to set up a mirror site of PHP & MYSQL between two distant sites

MySQLPHPsynchronization

I have a site which is located in US and I want to set up a mirror site in China, the site is using PHP + MYSQL and the network quality between two servers is terrible.

I tried set up a database-sync between two mysql databases but, there will always be conflicts due to the bad network quality (extremely high latency, packet loss, and sometimes cannot establish a connection at all).

Is there any better way to do the mirroring?

Best Answer

Many organizations deal with this challenge. There are a number of standard approaches:

  1. Mirror the static portions of the site to the remote region so that the amount of data fetched from a distant server is minimized. This can be enabled by a CDN or by your own DNS-based load balancing system, e.g. F5 GTM for an images sub-domain, etc.
  2. Parition the site by region with mostly unique content in each partition and some manual or automatic content duplication when needed (possibly enabled by the CMS.)
  3. Use a network acceleration service like akamai to serve your centrally hosted content to remote regions on faster network. The service doesn't mirror your content, rather it provides optimized path between the user and you with higher reliability and lower latency.

In certain circumstances, you might have a dynamic site that isn't edited very often. Rather than continuous database replication, you might take a snapshot approach. This would involve making frequent backups, copying them to the remote server, and restoring them on a schedule.