I have a website runing on a typical setup: Linux, Apache, PHP, MySQL.
However, what's not typical about it, is that it's getting tons of traffic (400,000+ visits a day) and so, efficiency is becoming more and more important to me.
I'm constantly looking for things I could optimize and, right now, my attention is focused on PHP's session files.
There's a hell lot of session files constantly being read and created on the /tmp
directory.
So my question is: Is it a good idea to store the session files in /dev/shm
(tmpfs) in order to speed things up a little bit??
/dev/shm
: NO!/dev/shm
has a defined meaning: It is intended to be used as the backing-store of the shared-memory interprocess communication subsystem. Files in there are supposed to be created using shm_open(3) and these files are generally supposed to be used as shared memory mappings between communicating processes. The fact that this location is implemented as a memory-backed filesystem is an implementation detail.If you want somewhere to store temporary files, create your own mount point for that purpose. Another option you should consider is using something different for these session files, like database storage (perhaps MySQL MEMORY tables using your own session handler or PgSQL).