High disk I/O when cache is used?

If you use file-backed memory mapping (e.g. apc.mmap_file_mask=/tmp/apc.XXXXXX) you might see elevated I/O.

Try setting apc.mmap_file_mask to use shared memory (e.g. /apc.shm.XXXXXX) or to /dev/zero (anonymous mmapped memory). Keeping the setting undefined defaults it to using anonymous mmapped memory.

Usually, mmapped files is a great thing:

  • Compared to storing something fully in memory, mmapped files usually require less memory
  • Compared to saving something to a file, mmapped files require less disk I/O (since writes can be aggregated together).

However, compared to storing something purely in memory, they do incur added I/O - considerably so when the file is continuously changing. The downside of not using mmapped files is a lack of persistence - your cache will not survive a restart, since it is stored only in memory.

One may suggest therefore, that while the cache was filling up and stabilizing, it was undergoing the most change, which had to be constantly written to disk; once the cache was full, the ttl for each object slowed the rate that data in the cache was being turned over, decreasing the change and reducing disk writes.


After a few days, now I want to come back with some graphs. The change improves much that situation. It reduces everything, except the IO service time (I think it's because there is no longer trivial small PHP file read which is cheap).

enter image description hereenter image description hereenter image description hereenter image description here

The server load (it was quite low already, so I had not discovered the change).

enter image description here