Linux Virtual File System (VFS) cache control?
We’ve bought a couple of very nice computers from Silicon Mechanics recently. They are cheap, compact, and hold lots of hard drives. We bought them mostly for scratchpad NFS servers and also figured that we’d use them somehow for our photo database. Trying to save some $$, we configured each with only 4 GB of RAM. As it happens, we were able to replace a very complex collection of multiple computers, each with multiple processes, with just a single Silicon Mechanics machine with eight hard drives in rat-simple hardware RAID 5 and two dual-core Opteron CPUs. The machine does pretty much nothing except run 8 lighttpd processes, each of which runs a single thread and serves multiple Web clients via async I/O. Jin set all of this up based mostly on comments here in this Weblog on an earlier posting.
Now that we’ve disabled the operating system writing “most recently read” times for every file served (“atime”), the server is acceptably fast. However, it is running disk-bound, with the RAID drives at 65 percent utilization, i.e., not much room for growth.
Our old SQUID server had 8 GB of RAM and was limited to serving thumbnail images. I suspect that if did obvious simple thing and filled this new computer up with 16 or 32 GB of RAM, we would have superb performance. But I’m wondering if we can’t save a few $$ and cheat a bit by controlling the Linux Virtual File System (VFS) cache. Right now we are not doing any caching in lighttpd, nor does the underlying ext3 system cache. This is by design. We want to keep only one copy of any given photo in RAM cluster-wide. I.e., we want the only copy to be in Linux VFS. We think we could get by with less RAM if we prevented Linux from pushing thumbnails out of the cache when pulling a medium or large JPEG from the RAID. In other words, we’d like to say “preserve 2 GB of the machine’s RAM for caching files of the form *-sm.jpg”, in effect having two caches for files, one for thumbnails and one for all other files.
Can this be done without massive amounts of C-code hacking and making it hard to upgrade the OS version?
Full post, including comments