Would a PHP application benefit from being served from a RAM drive?

Posted by Tom Marthenal on Server Fault See other posts from Server Fault or by Tom Marthenal
Published on 2012-07-08T06:22:55Z Indexed on 2012/07/08 9:17 UTC
Read the original article Hit count: 222

Filed under:
|
|

I am in charge of hosting a PHP application that is large and slow, but easy to scale. The application is entirely static, with writable disk storage needed. We've profiled the application, and the main bottleneck appears to come from loading the application and not the work the application does. The application is not CPU-intensive, although it does use a fair amount of memory (think Magento).

Currently we distribute it by having a series of servers with the same PHP files on their hard drive and a load balancer in front of them. Easy but expensive.

I've been reading about RAM disks and the IO benefits they offer, and was wondering if they would be well-suited to PHP applications.

Since PHP applications are loaded from disk for every request and often involve lots of different files (as opposed to being kept in memory like with a Java application), I would figure that disk performance can be a severe bottleneck.

Would placing the PHP files on a RAM disk and using the mount point as Apache's document root offer performance benefits? A startup script could create the RAM drive and then copy the files (which are plain-text and small) from a permanent location to the temporary RAM drive.

Does this make sense, or should I just trust the linux kernel to cache the appropriate files in memory by itself?

© Server Fault or respective owner

Related posts about linux

Related posts about ramdisk