Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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??

share|improve this question

1 Answer 1

up vote 2 down vote accepted
  • Storing in a memory-backed filesystem (like tmpfs) created for this purpose: maybe.
  • Storing in /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).

share|improve this answer
    
You might also want to look into Memcache. –  William Jul 12 '10 at 21:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.