title: Database geo-replication with low latency
body: <p>I have a website which I am currently hosting on a single server in Europe. To improve the latency for non-European users I would like to add local servers in the US and Asia.</p>
  
  <p>Keeping static files in sync is no problem. We add new content only once a day, so a simple rsync cron job will do fine to keep files updated.</p>
  
  <p>What I am totally stuck on is how to handle this on the database side? I would prefer a single master database that holds all user information, so that if a local server ever goes offline we always have the user data in the main server (regardless of backups).</p>
  
  <p>So far we consider 2 options:</p>
  
  <p><strong>A database with Geo Replication support</strong></p>
  
  <p>A database that supports geo replication out of the box. Should be very easy to setup and should have very low latency for DB writes (ie. without having to wait for a 'write success' message on the master server).</p>
  
  <p><strong>Programmatic approach with a master and a local database</strong></p>
  
  <p>A user is visiting from one region at the same time, so we could cook something up that connects to both the master and the local database. At first login all user information would be pulled from the master database and cached in the local database. All data generated by the user from then on, could be stored in the local database and synched back to the master database in the background. Could work, but seems overly complex and hard to fix if something goes out of sync?</p>
  
  <p><strong>A little more background information on the database</strong></p>
  
  <ul>
  <li>our database does a lot of reads and few writes</li>
  <li>database performance is not an issue at all. So we are only looking to improve the user experience (lower latency)</li>
  <li>a user does not generate much data (10kb in general, 200kb at maximum)</li>
  <li>we are not a bank or stock exchange, if some user data is synched back to the master server a minute or even a few minutes later it's not a big problem.</li>
  </ul>
  
  <p><strong>Our questions</strong></p>
  
  <ul>
  <li>is there a name that describes this specific problem? (so I can Google better)</li>
  <li>is there a database that does geo replication out of the box without latency penalty? (Couchbase perhaps?)</li>
  <li>would the programmatic approach be doable, or will it be a world of pain?</li>
  </ul>
  
  <p>I would be very thankful for any insights, or perhaps a link to an article that covers something like this. I'm sure there are more small scale websites out there which have run into this problem.</p>