Squid or Other HTTP Caches with SSD Cache Store

cachehttpraidsquidssd

I'm contemplating setting up a squid (or possibly varnish) cache on a system with SSD drives.

The obvious benefit is that these systems have great READ speeds and I expect my hit ratios to be fairly high.

Let's assume I can put 7 SSDs in to a RAID configuration.
(there are some cases that will let me pack in much much more)

Implementation questions:

  • Should I use RAID0? (I expect a drive to fail eventually, so this seems dangerous.)

  • Should I use RAID10? (This halves my disk footprint, which is costly.)

  • Should I use RAID5? (SSDs are known to have "bad" write performance and write limits, and all the extra parity writes may slow this down considerably.)

  • Should I just treat each disk as it's own squid datastore? (how well does squid handle multiple data stores? and what happens if/when one fails?)

  • Should I ignore datastores and just make the SSDs in to large SWAP partitions and let the linux VM do it's thing? (seems sloppy)

Any advice from folks using SSDs in production environments would be greatly appreciated. (esp if you're using them for HTTP caches)

Best Answer

We've been using varnish on ssd drives for the last 9 months, it has worked extremely well for us. We previously used a squid memory only cache with a carp layer. It worked, but memory fragmentation was a real problem requiring frequent restarts. Squid 2.x also will only use one core which makes it rather inefficient on current hardware.

For our site, which is very cache friendly, we see about about 10% cpu usage on an 8 core machine serving 100Mbit/s of traffic. In our tests we run out of bandwidth before we hit cpu limits with 2 1Gb ports.

I do have some advice for running varnish with an ssd cache.

  • Random write performance really matters. We tried several vendor's for ssd drives before settling on the intel x-25m. We've seen some post as little as .1MB/s for 4k random writes, we get 24MB/s 4k random writes with the x-25m.

  • Raid0. The cache in 2.0 is not persistent, so no need to worry about redundancy. This does make restarts hurt, but those are rare. You can do things like load a new config and purge objects without restart.

  • mmap mode. The varnish cache can be mmap'd to a file or use swap space. Using swap has not worked well for us, it tends to use more i/o bandwidth to serve the same amount of traffic. There is a 4 sector readahead in the linux swapin code, we wrote a patch to remove this but have not tried it in production.

  • Deadline scheduler. With 2.6.28+ this is ssd aware and performs well. We tried noop but found that deadline was fairer as i/o bandwidth becomes limited.

  • Disable read ahead. Since there is no rotational delay, no point in reading extra data just because you might need it. i/o bandwidth is precious on these things.

  • Run 2.6.28+. mmap of a lot of space on linux gives the memory manager a good workout, but the split lru patches help a lot. kswapd cpu usage dropped a lot when we updated.

We've posted our vcl file as well as several tools we use with varnish at link text. The vcl also includes a neat hack implementing a very fast geoiplookup server based on the maxmind database.