With TMPFS you can dramatically improve the speed of mod_pagespeed and the webpages served by it. TMPFS will store/serve the optimized PageSpeed output directly from RAM!
The PageSpeed module in a nutshell applies several optimizations to the output sent by your server before it is sent to the client's browser.
[ Server Outputs ] ===> [ PageSpeed Module Optimizes Output ] ===> [ Clients Browser Receives Optimized Output ]
The optimizations are quite impressive indeed, including optimizing images, HTML, CSS/JS, whitespace-minification, etc. However, since maybe 100 visitors to your site may request the same page at the same time, it would be inefficient for the PageSpeed optimization to have to run the same opimizations on the same outputs for every visitor. So, the PageSpeed optimizations are saved to the server disk in a temporary location. That way, the first visitor is the only request that requires PageSpeed to run all the CPU-intensive tasks like optimizing images, and those optimized images are then saved to disk, so that the next 99 visitors will be served directly from the disk and will not have to do all the work over again for each request and visitor.
The downside to this is obvious to anyone with a solid grasp of system-performance.. Disk I/O! The disk can only do so much activity at a time, and it has physical limits to the speed and amount of I/O it can do at any one time. Meaning that if you had 1000 visitors all accessing the same PageSpeed-optimized image file from disk on each request, the Disk I/O would become a serious bottleneck (though still much much faster than having to do the optimizations each time for each request).
A Disk just stores binary 0's and 1's, and likewise RAM does the same. The difference is that RAM is at least 30x faster. This is why Google's internal systems running google.com searches are all RAM-based. They also use RAM-based filesystems to store all the pagerank/linking data which makes parsing and computing that data way faster.
In order to save, retrieve, locate, and modify data on a Disk, you need a filesystem. Windows uses a lot of pathetic filesystems such as NTFS. Linux OTOH, uses cutting-edge filesystems such as ext4, ZFS, XFS, ReiserFS, and of course, GoogleFS.
Unlike Disks, RAM does not retain the 0's and 1's when the power goes off, so having a filesystem on top of RAM didn't make sense... The GNU/Linux developers went for it anyway and several RAM-based filesystems were created. The easiest and best is called TMPFS.
TMPFS lets you save, retrieve, locate, and modify the 0's and 1's on a RAM device in the exact same way you use a hard-drive.. Only, you wouldn't use TMPFS to store things since a reboot or power-outage will always clear RAM.
One of the easiest illustrations of how tmpfs can act like a 30x super-charger is this. Most browsers automatically request a sites favicon.ico file. If you had 10k visitors requesting the favicon.ico file at the same time it could cause a Disk I/O bottleneck. So what you could do instead is create a TMPFS in Ram and put the favicon.ico file there instead, then those 10k visitors requesting it at the same time would be served it directly from RAM!
So the idea here is to setup PageSpeed so that all the optimized images, white-space minified files, combined js files, etc.. are saved not to the slow Disk but are saved to the fast TMPFS. Then all of those optimized files are served directly from RAM! This not only improves the speed at which visitors receive the files, but also allows many many more visitors to be served at the same time. And it also improves the speed at which the PageSpeed module can generate, create, and update those optimized files.
First thing to do is shutdown apache/nginx. Then you will prepare and build the tmpfs filesystem.
# mkdir -pv /tmp/pgsp
Get the uid and gid first:
# id apache, which gives me:
Now add this line to your
Finally, make sure it mounts automatically
# mount -a
Then check that it is listed in the output of mount
# mount tmpfs on /tmp/pgsp type tmpfs (rw,noatime,gid=38,uid=38,size=200m,mode=0775)
Now that the tmpfs is all setup you just need to setup the Pagespeed Module to use it. Of course you will first need to install the module if you don't already have it.
In the Apache/Nginx configuration file provided by mod_pagespeed, such as
/etc/httpd/conf.d/pagespeed.conf, you need to set the directive ModPagespeedFileCachePath to the location of the tmpfs filesystem.