Strange memcached behavior on stress test

Janning Vygen vygen at planwerk6.de
Mon Jun 12 08:03:16 UTC 2006


Am Montag, 12. Juni 2006 08:12 schrieb Garth Webb:
> I don't know if you've read about how memcached works or not, ut
> assigning it '-m 1024' doesn't mean that it will store 1 GB of data
> before it starts dropping old items.  It means that it will allocate
> 1024 1MB slabs for caching.  Each 1MB slab will hold 1MB of data within
> a certain size range.
>
> For example, if you give '-m 5' and then start filling the cache with
> random amounts of data, you might get a 1MB slab for each of:
>
>   Slab 1 :  16 bytes
>   Slab 2 :  32 bytes
>   Slab 3 :  64 bytes
>   Slab 4 : 128 bytes
>   Slab 5 : 256 bytes
>
> If your data a lot of things above 16 bytes but below 32 bytes,
> memcached may dedicate two 32 byte slabs:
>
>   Slab 1 :  16 bytes
>   Slab 2 :  32 bytes
>   Slab 3 :  32 bytes
>   Slab 4 : 128 bytes
>   Slab 5 : 256 bytes
>
> At this point if all new data you cache fits within these slab sizes, if
> the cache gets full, it will push out older data.  However, if you now
> try to cache something that is 1K, you will get an "out of memory" error
> because memcached doesn't have a slab large enough to hold that data and
> it won't dump an entire slab to make room for it.
>
> Usually memcached won't create slabs so tightly clustered in size
> (though that depends on your usage pattern) but this is one condition
> where you'll get a set problem and an out of memory error even if you
> have space left in individual slabs.

Thank you garth for this detailed explanation. Now i think i understood my 
problem. My session data is very different in size. So my allocated "slabs" 
are "full" and a new slab can't be allocated.

kind regards
Janning

-- 
PLANWERK 6 websolutions
Venloer Straße 8, 40477 Düsseldorf
Tel: (0211) 302666-0
Fax: (0211) 302666-10 
http://www.planwerk6.de/


More information about the memcached mailing list