I consistently get an out of memory error when performing < 44 byte (key+data) puts to memcache, but when 'put'-ing the same key with data that is long enough to exceed 44 chars key + data , I succeed. I observe this behavior using both the ruby client (memcache-client
1.5) and the python one (python-memcached), although the python client seems to break at 59 chars, rather than 44.<br><br>I see something vaguely similar on the lists in early 2006:<br><a href="http://www.nabble.com/%22SERVER_ERROR-out-of-memory%22-when-changing-cache-entry-pattern-t4346764.html">
http://www.nabble.com/%22SERVER_ERROR-out-of-memory%22-when-changing-cache-entry-pattern-t4346764.html</a><br><br>but my error is consistent, where theirs seems to have been sporadic.<br><br><br><br>I'm running memcached
1.2.2 with the following options:<br><br>memcached -d -p 11211 -u nobody -c 1024 -m 3072<br><br>The offending servers are recent CentOS running 3G of cache each on 32-bit boxes with 4G ram-if it matters, I can get details about these.
<br><br><br><br>Very detailed:<br><br>Here is a ruby console session,<br><br>>> s = "1234567890" * 100<br>=> "1234567890.....{long string elided for brevity.}"<br>>> s.first(10)<br>=> "1234567890"
<br>>> CACHE.set('foo', s.first(1))<br>MemCache::MemCacheError: out of memory<br> from /usr/lib/ruby/gems/1.8/gems/memcache-client-1.5.0/lib/memcache.rb:307:in `set'<br> from (irb):16<br> from :0
<br>>> CACHE.set('foo', s.first(50))<br>=> nil<br>>> CACHE.get('foo')<br>=> "12345678901234567890123456789012345678901234567890"<br>>> CACHE.set('foo', s.first(30))
<br>MemCache::MemCacheError: out of memory<br> from /usr/lib/ruby/gems/1.8/gems/memcache-client-1.5.0/lib/memcache.rb:307:in `set'<br> from (irb):31<br> from :0<br>>> CACHE.set('foo',
s.first(40))<br>=> nil<br>>> CACHE.get('foo')<br>=> "1234567890123456789012345678901234567890"<br>>> CACHE.set('foo', s.first(32))<br>MemCache::MemCacheError: out of memory<br> from /usr/lib/ruby/gems/1.8/gems/memcache-
client-1.5.0/lib/memcache.rb:307:in `set'<br> from (irb):34<br> from :0<br>>> CACHE.set('foo', s.first(33))<br>=> nil<br>>> CACHE.get('foo')<br>=> "123456789012345678901234567890123"
<br>>> CACHE.get('foobar')<br>=> nil<br>>> CACHE.set('foobar', s.first(32))<br>=> nil<br>>> CACHE.get('foobar')<br>=> "12345678901234567890123456789012"<br>>>
CACHE.set('foobar', s.first(30))<br>=> nil<br>>> CACHE.get('foobar')<br>=> "123456789012345678901234567890"<br>>> CACHE.set('foobar', s.first(29))<br>MemCache::MemCacheError: out of memory
<br> from /usr/lib/ruby/gems/1.8/gems/memcache-client-1.5.0/lib/memcache.rb:307:in `set'<br> from (irb):47<br> from :0<br><br><br>So it looks like anything under 36 bytes (key + data) has a problem. The client I use prefixes keys with an 8-char string, so that's actually 44 chars key + data
<br><br>Using python-memcached, I got substantially the same results, only the break happened at 59 chars key + data.<br><br>>>> s = "1234567890" * 10<br>>>> mc.set("key", s[0:56])<br>
1<br>>>> mc.get("key")<br>'12345678901234567890123456789012345678901234567890123456'<br><br>>>> mc.set("key", s[0:55])<br>MemCached: while expecting 'STORED', got unexpected response 'SERVER_ERROR out of memory'
<br>1<br>>>> mc.get("key")<br>'12345678901234567890123456789012345678901234567890123456'<br>>>> mc.set("k", s[0:56])<br>MemCached: while expecting 'STORED', got unexpected response 'SERVER_ERROR out of memory'
<br>1<br>>>> mc.set("k", s[0:58])<br>1<br>>>> mc.get("k")<br>'1234567890123456789012345678901234567890123456789012345678'<br><br><br><br>If it matters, here is the response from stats:
<br><br>>> CACHE.stats<br>=> {"x.x.x.x:11211"=>{"bytes"=>2678831108, "pid"=>2613, "connection_structures"=>47, "threads"=>4, "evictions"=>7397, "time"=>1191948397, "pointer_size"=>32, "limit_maxbytes"=>3221225472, "cmd_get"=>54170155, "version"=>"
1.2.2", "bytes_written"=>37964380497, "cmd_set"=>25110788, "get_misses"=>11659284, "total_connections"=>2041765, "curr_connections"=>43, "curr_items"=>4374286, "uptime"=>2334717, "get_hits"=>42510871, "total_items"=>25110788, "rusage_system"=>
2039.975876, "rusage_user"=>612.713853, "bytes_read"=>75534170186}, "x.x.x.y:11211"=>{"bytes"=>2678220092, "pid"=>2516, "connection_structures"=>47, "threads"=>4, "evictions"=>10624, "time"=>1191951946, "pointer_size"=>32, "limit_maxbytes"=>3221225472, "cmd_get"=>56914534, "version"=>"
1.2.2", "bytes_written"=>34812915115, "cmd_set"=>25042621, "get_misses"=>11378051, "total_connections"=>2041833, "curr_connections"=>43, "curr_items"=>4542475, "uptime"=>2334736, "get_hits"=>45536483, "total_items"=>25042621, "rusage_system"=>
2115.619376, "rusage_user"=>631.239037, "bytes_read"=>75855048310}}<br clear="all"><br>