Apache serves file from RAM

I would like to store the content on my VPS in RAM as shown on disk. Is there a way to do this using Apache and PHP? I want to do this to minimize the time it takes to retrieve the content.

Also, is RAM storage generally faster than SSD storage?

+3


source to share


1 answer


I'm not an expert on this topic, but here's what I would like to try as a basic approach:

I would keep my application code (including resources like CSS, JS, etc.) to keep it simple) in a location on my hard drive. I would have a RAM mount like:

vi /etc/fstab
tmpfs       /mnt/ramdisk tmpfs   nodev,nosuid,noexec,nodiratime,size=1024M   0 0

      



and when the system starts up I will copy from HDD to HDD. Then I will have an HTTP server (apache) pointing to mount the RAM, also everything inside PHP will download the code from the RAM holder and not to the original location (for purposes of rooting, the hard disk source location does not exist).

For the actual content, I would use an in-memory DB . If the content is rich in media, some RAM cache such as varnish can be used for this part .

Of course, there is a variation on this strategy, or maybe even better solutions, but that also depends on your specific circumstances and you haven't talked too much about it.

+1


source







All Articles