Memcache Performance

42 views
Skip to first unread message

Martyn

unread,
Aug 5, 2009, 1:35:47 PM8/5/09
to Google App Engine
While profiling some datastore performance I discovered a hit where I
hadn't expected one.

It turns out that memcache is taking ~13 ms for each put/get or inc/
dec.

Since I am using a memcache atomic increment as a VM semaphore this
results in a 26ms overhead to acquire and release the "lock".

I'm sure that somewhere I read that memcache takes ~3ms for a request.

Here is the code I used to test:
MemcacheService mc = MemcacheServiceFactory.getMemcacheService();
mc.put("testSemaphore", new Long(0));
timer.start();
for (int i = 0; i < 50; i++) {
mc.increment("testSemaphore", 1);
mc.increment("testSemaphore", -1);
}
out.append("<tr><td>Cache increment/decrements</td><td>50</td><td>"
+ timer.elapsed() + "</td></tr>");

timer.start();
for (int i = 0; i < 50; i++) {
mc.put("testSemaphore", new Long(23));
mc.get("testSemaphore");
}
out.append("<tr><td>Cache put/gets</td><td>50</td><td>" +
timer.elapsed() + "</td></tr>");

I get ~1380ms for each of the tests, so approx 14ms for each api call.

Any suggestions?

- Martyn

Martyn

unread,
Aug 6, 2009, 5:08:19 AM8/6/09
to Google App Engine
This is from a Google Code resource:

"Memcache is a distributed RAM cache in which you can store transient
data using a key-value model. Writes to memcache never touch the disk
and are approximately 10 times faster in comparison to writes to the
datastore. Also, direct gets to memcache are approximately five times
faster than a get request to the datastore."

I am not finding this, specifically, a batch write of 2 2K Blob
entities takes < 60ms

Let's assume the worst case that a single Blob put would take 60ms

A memcache put is taking around 13ms which is definitely not one tenth
the time.
A memcache get is also taking the same time.

Martyn

unread,
Aug 6, 2009, 8:23:28 AM8/6/09
to Google App Engine
.hmmmm...

checking the AppEngine status Latency figures...

I note that Datastore best Put latency is ~60ms but frequently over
80ms, which is what I see in my performance tests.

However, the memcache latency is reported at ~5ms, which is definitely
NOT what I see, I am experiencing almost three times that.

Jeff S (Google)

unread,
Aug 10, 2009, 5:58:52 PM8/10/09
to google-a...@googlegroups.com
Hi Martyn,

Nick has chimed in on the question in the following thread:

http://groups.google.com/group/google-appengine/browse_thread/thread/5c9b5ecc25499250

Thank you,

Jeff
Reply all
Reply to author
Forward
0 new messages