Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which is faster/better for caching, File System or Memcached?

I don't think it's clear to me yet, is it faster to read things from a file or from memcached? Why?

like image 338
Lance Avatar asked Jun 30 '10 09:06

Lance


People also ask

Is Redis faster than filesystem?

File reads are cached by the OS filesystem, so they are fast memory transfer operations between the kernel and Python. There is no disk I/O involved here. With Redis, you have to pay for the cost of the roundtrips, so it is much slower.

Why Redis cache is better than memcache?

When storing data, Redis stores data as specific data types, whereas Memcached only stores data as strings. Because of this, Redis can change data in place without having to re-upload the entire data value. This reduces network overhead.

Why Memcached is faster than Redis?

Redis uses a single core and shows better performance than Memcached in storing small datasets when measured in terms of cores. Memcached implements a multi-threaded architecture by utilizing multiple cores. Therefore, for storing larger datasets, Memcached can perform better than Redis.

How fast is Memcached?

memcached can process over 50 million keys per second on a 48 core machine using only RAM and heavy batching.


1 Answers

Memcached is faster, but the memory is limited. HDD is huge, but I/O is slow compared to memory. You should put the hottest things to memcached, and all the others can go to cache files.
(Or man up and invest some money into more memory like these guys :)

For some benchmarks see: Cache Performance Comparison (File, Memcached, Query Cache, APC)

In theory:

Read 1 MB sequentially from memory       250,000 ns Disk seek                             10,000,000 ns 

http://www.cs.cornell.edu/projects/ladis2009/talks/dean-keynote-ladis2009.pdf

like image 81
25 revs, 4 users 83% Avatar answered Sep 21 '22 21:09

25 revs, 4 users 83%