This document discusses bcache, a Linux kernel feature that allows using solid-state drives (SSDs) as a cache for hard disk drives (HDDs). It creates a hybrid volume for improved performance. Bcache can cache an unlimited number of backing devices and features write-through caching, detection of sequential I/O, and throttling to prevent SSD congestion. Using bcache with Aerospike provides persistence with near SSD performance at lower cost than SSD-only or RAM-backed deployments.
2. Agenda
● Bcache
● What is bcache?
– Features
● Why bcache?
● How to use bcache?
● Why bcache with Aerospike?
3. ● Anshu Prateek
● Aerospike Devops Lead
● Ex - Yahoo! Search Operations
● http://about.me/anshuprateek
● anshu@aerospike.com
4. bcache
● Block – cache
● cache in the Linux kernel's block layer
● Starting Kernel >=3.10 (June 2013)
5. bcache?
● Kent Overstreet
● http://bcache.evilpiepirate.org
● https://github.com/g2p/bcache-tools.git
● GNU General Public License (GPL)
6. 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
9. 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)
10. 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).
11. 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).
12. 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.
13. Why bcache?
● BIG HDD
– But slow
● Fast SSD
– Smaller, comparatively costlier..
– But cheaper than RAM!
20. How to w/ Aerospike?
● Caching Mode
Default Write through
● Caching device
– 2 or more
● Backing device
– Same size as caching device
21. 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.
22. 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.
23. How to w/ Aerospike?
● http://www.aerospike.com/docs/operations/plan/
ssd/bcache/asbcache/
24. Why w/ Aerospike?
● Cloud providers
– No persistence w/ performance
● So far..
– In-memory backed with persistence
– Costly!
● Bcache provides persistence w/ performance
– At upto 80% the cost saving!!