title: Why is Google Appengine so slow connecting to CloudSQL
body: <p>I am seeing a drastic difference in latency between development and production when connecting to a CloudSQL backend, much more so than I would expect.</p>
  
  <p>I ran a test where:</p>
  
  <ol>
  <li>I fetched 125, 250, 500, 1000 and 2000 rows (row size approximately 30bytes)</li>
  <li>I fetched each row size 20 times, to get a good sampling of the time</li>
  </ol>
  
  <p>The test was run in three environments:</p>
  
  <ol>
  <li>Hosted appengine</li>
  <li>Development mode locally, but connecting to CloudSQL via static IP</li>
  <li>Development mode locally and connecting to a local VM running MySQL</li>
  </ol>
  
  <p>Here you can see the results:
  <img src="https://i.stack.imgur.com/mTaWQ.png" alt="Graph of results"></p>
  
  <p>Now I would expect some speed fluctuations on the order of 50ms-200ms but 3-4 <em>seconds</em> seems a bit high.</p>
  
  <p>I'm new to appengine, so any newb mistakes that might be causing this? Or other suggestions? I ran a profiler on my code in appengine and there is a call to _apiProxy.Event "wait" that eats up at least 500ms, but didn't go up more than 750ms, other than that, there was any long running calls. A number of shorter running calls that eventually add up of course, but it's not like I have a loop that needs to be tuned or anything.</p>
  
  <p>Thanks in advance! </p>