What is bcache? ● creates hybrid volumes and provides performance improvements ● one or more fast storage devices, such as flash-based solid-state drives (SSDs), to act as a cache for one or more slower storage devices, such as hard disk drives
Features ● A single cache device can be used to cache an arbitrary number of backing devices, and backing devices can be attached and detached at runtime, while mounted and in use (they run in passthrough mode when they don't have a cache). ● (But not multiple caching device for a single backing device)
Features ● Recovers from unclean shutdown - writes are not completed until the cache is consistent with respect to the backing device (Internally, bcache doesn't distinguish between clean and unclean shutdown). ● Detects and bypasses sequential IO (with a configurable threshold, and can be disabled).
Features ● Throttles traffic to the SSD if it becomes congested, detected by latency to the SSD exceeding a configurable threshold (useful if you've got one SSD for many disks). ● Readahead on cache miss (disabled by default).
Features ● Highly efficient writeback implementation; dirty data is always written out in sorted order, and if writeback_percent is enabled background writeback is smoothly throttled with a PD controller to keep around that percentage of the cache dirty. ● Very high performance b+ tree - bcache is capable of around 1M iops on random reads, if your hardware is fast enough.
Why bcache? ● BIG HDD – But slow ● Fast SSD – Smaller, comparatively costlier.. – But cheaper than RAM!
Why bcache? ● Persistence (in cloud) - Is network attached - hence, slower compared to direct attached ● Desktop / laptop / servers
Why bcache? ● Performance of direct attached (ephemeral) + ● Persistence of storage
How to..? ● Kernel >=3.10 – Fedora, Ubuntu, Amazon Linux ● SSD – Direct attached is better ● Bigger/slower HDD/Network SSD
How to..? ● Install bcache tools ● Unmount caching and backing device ● Wipe existing FS (backup!) – wipefs -a /dev/xvdb ● make-bcache -B /dev/xvdf -C /dev/xvdb ● Done!
How to..? ● /sys/fs/bcache ● /sys/block/bcache0
How to w/ Aerospike? ● Caching Mode Default Write through ● Caching device – 2 or more ● Backing device – Same size as caching device
How to w/ Aerospike? ● Tuning ● By default, bcache does not cache sequential IO, just the random reads and writes that SSDs excel at. For Aerospike, we recommend enabling caching of sequential IO as well. ● Disable congestion throttling on bcache to avoid cache misses.
How to w/ Aerospike? ● We recommend using a one to one mapping between backing and caching devices to avoid cache misses. Avoid configuring a single caching device with multiple backing devices. ● Though bcache documentation shows way of creating and attaching caching and backing devices in a single command (make-bcache -B /dev/backing -C /dev/caching), we have seen problems when using this single command in cloud providers due to known bugs. Hence, we suggest not using this currently and instead use two invocations to setup the backing device and the caching device. These bugs have been fixed in the latest bcache but the fixed kernel is not available for all distros yet.