title: Google App Engine low memcache performance
body: <p>Memcache is one of those things where the solution could be absolutely anything, and no one ever really gives a decent answer, maybe because there is none. So I'm not looking for a direct answer, but maybe just something to get me going in the right direction.</p>
  
  <p>For a typical request, here is my AppStats info:</p>
  
  <p><img src="https://i.stack.imgur.com/o0CgL.png" alt="enter image description here"></p>
  
  <p>So, out of a total 440 ms request, I spend 342 ms in memcache. And here I figured memcache was supposed to be lightning fast. I must be doing something wrong.</p>
  
  <p>Looking at my memcache statistics in my admin console, I have this:</p>
  
  <pre><code>Hit count:  3848
  Miss count: 21382
  Hit ratio:  15%
  </code></pre>
  
  <p>I'm no expert on this stuff, but I'm pretty sure 15% is terrible. </p>
  
  <p>The typical request above is a bit too detailed to explain, but basically, I create and put a new entity, which also updates and puts a parent entity, which also updates and puts any users associated with the parent entity. </p>
  
  <p>Throughout all this, I always get by key, never query. Oh and I'm using NDB, so all the basic <a href="https://developers.google.com/appengine/docs/python/ndb/cache" rel="nofollow noreferrer">memcache stuff is handled automatically</a>. So I never actually touch memcache manually on my own in my code.</p>
  
  <p>Any ideas?</p>
  
  <p>Edit: Here is the breakdown of my request</p>
  
  <p><img src="https://i.stack.imgur.com/yAxW2.png" alt="enter image description here"></p>
  
  <p>So I only have 2 datastore gets and 2 puts. The rest is automatically handled memcache stuff. Why is it doing so much work? Would I be better off handling this stuff manually?</p>