Bits and pieces.

Speedup block devices with bcache

Comparing NVMe drives with normal SSDs or even SAS/SATA HDDs is like comparing apples with pears in terms of performance.

However, it’s not always feasible to run everything on all-flash storage, as it’s still quite costly. Thats were bcache steps into the game.

Whats bcache?

bcache is a kernel module, which adds a caching layer for block devices in order to speedup i/o performance for conventional drives such as normal SATA/SAS HDDs or SSDs.

It acts like a foreman, deciding which i/o can be cached and redirecting those to the underlying block or cache devices.

How well does bcache perform?

In our cloud storage setup (at combahton), we’re running almost every glusterfs node with bcache and nvme cache drives. That works quite good and provides a serious i/o benefit over uncached storage.

Debian Installation

Implementation is quite simple:

apt-get install bcache-tools

In our setup /dev/md0 is a nvme raid1, /dev/sda3 a partition on the underlying block device (for example Hardware Raid 1):

make-bcache -B /dev/sda3 -C /dev/md0

Thats it, you should able to see /dev/bcache0 right now, which is your cached device. You can create partitions or directly a filesystem on your newly created device.

Activating writeback cache

In order to activate writebach cache mode, the setting needs to be configured as parameter with bcache’s sysfs space:

echo writeback > /sys/block/bcache*/bcache/cache_mode

Otherwise bcache will only act as read cache.

Leave a Reply

Your email address will not be published. Required fields are marked *