title: Can we monitor with Node.js whether MySQL replication has been successful?
body: <p>We are building a Node.js application that is connected to a MySQL database. The main purpose of this application is to manage a sport event; manage the entries, draw, results, etc. We host this application at a hosting provider(the global instance), but because we don't want to take any risk with a failing internet connection at the event location, we also want to be able to run a local instance of this server that communicates with the global instance.</p>
  
  <p>The local instance has to be the 'master' instance of the specific event, that we would like to use for editing match information. We would like to use the global instance as 'publish' server that serves live match information to viewers on the website.</p>
  
  <p>Therefore we are planning to do the following:</p>
  
  <p>On the global instance (MySQL): Master the 'main' database (with user information, etc.) and slave the event specific database.</p>
  
  <p>On the local instance (MySQL): Slave the 'main' database and master the event specific database.</p>
  
  <p>Once we have saved a result in the local event database, it will start to replicate that information with the global database.</p>
  
  <p><strong>The problem</strong></p>
  
  <p>Our problem is that we want to publish the live match information as fast as possible. But we don't know how we can tell whether the global node.js application's database has been updated. Long polling on the MySQL database doesn't seem to be a very good idea. Sending an event from the local to the global node.js application could be a solution, but then the local application needs to know when the replication is finished.</p>
  
  <p>We have been thinking about this problem for a long time. Is there a way to generate a Node.js event when the replication is ready, or is there a whole different method which we can use to gain the same result?</p>