Memcached slower than Caching in files?

BUSTARRET, Jean-Francois JFBUSTARRET at tf1.fr
Mon Oct 30 09:02:13 UTC 2006


- Do you use file locking ?
If you don't use file locking, you might experience data consistency problems (processes reading half written files). Cache_Lite uses checksums to guarantee the consistency of cached files, which you might also need to use.

A single process benchmark does not measure the impact of file-locking in terms of performance (or the impact of not having locking in terms of consistency). You should also test through your webserver.

- You should test with thousands of cached files (or some number typical of your use). File-based caches (especially on NFS) can be very inefficient if the directory structure isn't well thought.

IMHO, in a single server/single process setup, memcache would be less efficient than files.

As far as I am concerned, I did experience performance problems with memcache (the PHP pecl API), that were solved by :
memcache.chunk_size = 32768

Jean-François Bustarret

> -----Message d'origine-----
> De : memcached-bounces at lists.danga.com 
> [mailto:memcached-bounces at lists.danga.com] De la part de 
> Silvan Mühlemann
> Envoyé : lundi 30 octobre 2006 09:00
> À : memcached at lists.danga.com
> Objet : Memcached slower than Caching in files?
> 
> Hi
> 
> 
> We are running a high-traffic photo album website (100 million page 
> impressions a month). http://www.tilllate.com
> 
> Currently we are using Cache/Lite to cache query results or 
> pregenerated 
> HTML pages. Cache/Lite (http://pear.php.net/*Cache*_*Lite)* 
> is storing 
> the data in files. These files are either stored on the local 
> drive or 
> on a NFS share.
> 
> We are thinking about moving memcached for performance reasons.
> 
> To compare both methods (file vs. memcache) I have written a 
> benchmark. 
> Here's the setup:
> 
> SETUP:
> - PHP 5.1.6 on Linux 2.6.14, memcached 1.1.12
> - 10 different sample items to cache
> - every item is a random ASCII-String of 100'000 characters.
> - every iteration has the following steps
>   - choose one of the 10 items to cache by random
>   - if they are already in the cache, retrieve them
>   - if not, store them in the cache
> - there are 1000 iterations.
> - the random number generator produces the same sequence of 
> numbers for 
> each test case to ensure comparability among the tests
> - the test scenario produces a hit rate of exactly 99.0%.
> - memcached setup:
>   - the memcached has 64MB of memory
>   - the connection to the memcached is only being set up once 
> per test case.
> - disks: IDE-Disks (hdparm -t: 40MB/s)
> 
> TEST CASES:
> a) Cache items in local files: 345ms
> b) Cache items in local memcache: 1003ms
> c) Cache items in remote (NFS) files: 3854ms
> d) Cache items in remote memcache: 16607ms
> 
> I am surprised caching in memcache is over 3 times slower 
> than caching 
> in files. I expected memcache to be much faster. Or ist the test 
> scenario not adequate for memcache?
> 
> Is there something I overlooked when I did my tests? With 
> this result I 
> should stick to caching in files instead of using memcache.
> 
> 
> Silvan
> http://techblog.tilllate.com
>   
> 


More information about the memcached mailing list