How can I use my small SSD as a cache for a larger hard disk?

There are several ways to use an SSD as a cache for your regular hard drive. This is not a new idea, and already has several implementations.

In Windows:

The best implementation is by NVelo: Dataplex - It has read caching and optional write caching. Unfortunately, like ExpressCache it is available to OEMs only. The cheapest way to get it is to buy an OCZ SSD which packages a PCIE adapter with a small SSD and uses the dataplex software to cache your existing harddrive.

There are however, pure software implementations too: FancyCache - It works like you might expect performing read and write caching at the block layer. It primarily exists as a memory cache, but recently has gained support for a second layer SSD cache (a bit like the ZFS L2ARC), which can be arbitrarily large.

If you are just looking to max out on IOPS at the cost of write durability (perfectly fine in conjunction with a UPS for example), an alternative might be something like: SuperCache - This will use RAM only, no SSD. But unlike the others, will happily exceed 100,000 IOPS on commodity hardware. Very useful for caching the block device containing database indexes for example. Essentially giving RAM-Disk like performance for any sized volume (assuming the underlying device can keep up with the write volume).

In Linux, things are a bit nicer:

As a previous poster mentioned, you have Flashcache - It works rather well, but its performance varies greatly with your workload. In many cases with poor access locality it will not perform as well as you might expect. Not sure why that is, but for most workloads this is a great option.

The best option (though the code is still not quite "production ready") is bcache (more information here, though some of if is outdated) - It has the best performance of any SSD cache I have yet tried, and unlike all the other options mentioned supports caching multiple block devices on a single cache. It also supports (though I haven't personally tried this, it may not work yet) multiple cache devices, so you can use multiple cheaper SSDs for maximising your IOPS. The code is in a git repository: git://evilpiepirate.org/~kent/linux-bcache.git. There is talk of merging it into the next kernel release, though it hasn't yet been decided for sure.

Personally I find the best performing option is bcache (my workload is mostly database related, though I also cache my main laptop in its entirety). In my experience the sequential write throughput of the HDD is often the bottleneck, as the cache fills up fast and the HDD needs to write the cached sectors, so the faster the better. This is of course for a write heavy workload, in a more balanced read-write workload things will likely be different.

I should also warn you, that at full speed, you will burn through the write limits of your SSD fairly quickly. I'm currently on my third OCZ Vertex 3. SSDs though very very fast, are simply not very durable, so expect to replace them every few months.


There is a very interesting piece of software for Linux, in use by very busy servers:

https://github.com/facebook/flashcache

On a SATAII, 8 magnetic rotational drives in a RAID6 setup I get serious performance boost. Random read with SATAIII flashcache SSD device (540 read, 420 write) saturates my SATAII bus to almost 90-95% - I have 280MB read (in peak times), 270MB write (only in simulated load... never reached in production). It lasts for about a half year now. The disk drive writes are... 20-30MB/s - use spare I/O time...


How large your SSD is?

Probably the best effect you'll achieve by installing the entire OS and software on SSD, while storing bulks of data on your HDD.

If your SSD is small, then it could be useful to put a pagefile on it. I doubt Windows will put much of your files to cache, but, at least, it will allow you to have recent-used applications memory and files cache in RAM, while allowing for fast switching to not-so-recent used applications (which will reside in pagefile which is, in turn, on SSD).