title: how to simply handle a (very) short mysql replication lag
body: <p>I have an application (php) running with MySQL 5.5 (1 master and 1 slave)</p>
  
  <p>I use to dispatch read/write on master / slave.</p>
  
  <p>When I create a new record (a user or something like that) I write it on the master and when I reload the page, I load it from the slave.</p>
  
  <p>Example:</p>
  
  <pre><code>...
  if ($_GET['id'])
  {
      #Load user
      $user = $sql-&gt;load('user', $_GET['id']);
  
      if ($user == false)
      {
          throw exception('User not found');
      }
  }
  else if ($_POST['create]')
  {
      #Create a new user
  
      $user_id = $sql-&gt;insert('user', $_POST);
      $mvc-&gt;reload('?id=' . $user_id);
      exit();
  }
  ...
  </code></pre>
  
  <p>But when the master is really performant (quick insert) and the replication is not (lag = 0.3 - 1 sec), the reload will not work...</p>
  
  <p>What are the best practice to handle that</p>
  
  <p>Some solutions:</p>
  
  <ul>
  <li>Database optimisation for reducing the lag (very difficult)</li>
  <li>sleep(1) before reading or after writing ... not very elegant</li>
  </ul>