RapidCache


				

				

Note - Although considered stable, this module and its functionality is still in beta. Please use with caution at least until it is considered production stable.

Contents

Description

Introduced in the 2.0 release, RapidCache or rxcache is designed to leverage the high speed performing technologies of the RapidDisk RAM disk and utilizing the Device Mapper framework, map an rxdsk volume to act as a block device's Write/Read-through cache. This can significantly boost the performance of a local or remote disk device. The 2.0 release is supported for Linux kernels 2.6.32 and later.

What is Write-Through and Read-Through Cache?

This is where an application treats cache as the main data store and reads data from it and writes data to it. The cache is responsible for reading and writing this data to the permanent storage volume, thereby relieving the application of this responsibility.

In RapidCache, all writes are cached to an rxdsk volume but also written to disk immediately. All disk reads are cached. Cache is not persistent over device removal, reboots or after you remove the DM mapping. This module does not store any cache metadata on RapidDisk volumes but instead in memory outside of rxdsk and the replacement policy is FIFO.

The best part of RapidCache is that you can map and unmap a cache drive to any volume at any appropriate time and it will not affect the integrity of the data. Again, an advantage seen only with the safest caching methods of Write/Read Through caching. So, one minute you can umount an existing volume, map it in a rxcache volume and remount it, while a few minutes later, you can return it back to its original and unmapped state. It is that simple and safe.

Diagram showcasing typical RxCache Configuration.

Environment(s) For Use

In order to use this and have it be effective, the administrator must evaluate the appropriate configuration with respect to their I/O profile which includes file and transfer sizes. It should also be noted that this module is most ideal in environments with frequent read operations, especially over the same data regions.

  • General block device caching for:
    • Locally attached disk devices.
    • Remotely attached disk devices mapped over a Storage Area Network (SAN).
  • Ideal for database requests (specifically data frequently accessed).
  • Also ideal for frequent small file read/write operations.

Do not use this in a virtual guest or with a loopback device. You will not see any performance improvements for reasons I do not feel like explaining at the moment. In fact, the performance will be worse in such environments. Only use this with an actual physical disk device.

Below is a table showcasing the performance achieved when accessing cached data via RapidCache:

Profile RxCACHE External USB (mechanical HDD)
4K xfer
32M file
32 depth
Seq Reads: 802 MB/s
Seq Writes: 68 MB/s
Ran Reads: 907 MB/s
Ran Writes: 2.8 MB/s
Seq Reads: 104 MB/s
Seq Writes: 70 MB/s
Ran Reads: 7.9 MB/s
Ran Writes: 2.8 MB/s

Note - Using RapidCache with 1 MByte transfers on the same hardware, reading cached data both sequentially and randomly can get as high as 1.0 - 1.2 GB/s and a bit more.

Usage

This section assumes you already have the rxdsk.ko module loaded with rxdsk devices already created and available block devices attached to the host system.

Kernel Module

In order to take advantage of this module, the rxdsk module will need to be loaded first. You can reference this procedure in the Download and Installation page.

To insert the rxcache module:

$ sudo modprobe rxcache


To remove the rxcache module:

$ sudo modprobe -r rxcache


To view the module's current version:

$ cat /proc/rxc
    RapidCache Version : 2.0b

Administration Tool

While the rxadm administration utility checks for all of these (except for the last) scenarios, it is worth noting the following:

  • You are not able to map any device currently in a mapping.
  • You are not able unmap a mounted mapping. You must first invoke a umount.
  • You are not able to detach an rxdsk if it is currently in a mapping.
  • Every mapping must have an rxdsk device selected as the caching drive.
  • Every mapping must have a typical block device that can be accessed via the /dev directory path selected as the source drive.
  • Please do not map one rxdsk device to another, it defeats the purpose of this module.


Listing all current mappings with detailed information:

 $ sudo rxadm --list
  rxadm 2.0b
  Copyright 2011-2012 Petros Koutoupis

  List of rxdsk device(s):

   RapidDisk Device 1: rxd0
          Size: 100663296

   RapidDisk Device 2: rxd1
          Size: 67108864

  List of rxcache mapping(s):

   RapidCache Target 1: rxc1
  0 204799 rxcache conf:
          rxd dev (/dev/rxd1), disk dev (/dev/sdc) mode (WRITETHROUGH)
          capacity(64M), associativity(512), block size(4K)
          total blocks(16384), cached blocks(0)
   Size Hist: 512:149053 1024:3 4096:126944

   RapidCache Target 2: rxc0
  0 4194303 rxcache conf:
          rxd dev (/dev/rxd0), disk dev (/dev/sdb) mode (WRITETHROUGH)
          capacity(96M), associativity(512), block size(4K)
          total blocks(24576), cached blocks(10188)
   Size Hist: 512:149053 1024:3 4096:126944



All newly mapped devices will be accessible from the /dev/mapper directory path. Creating a mapping:

 $ sudo rxadm --rxc-map rxd0 /dev/sdb 4
  rxadm 2.0b
  Copyright 2011-2012 Petros Koutoupis

  Command to map rxc0 with rxd0 and /dev/sdb has been sent.
  Verify with "--list"

Removing a mapping:

 $ sudo rxadm --rxc-unmap rxc0
  rxadm 2.0b
  Copyright 2011-2012 Petros Koutoupis

  Command to unmap rxc0 has been sent.
  Verify with "--list"

Working with a mapping:

  $ sudo mke2fs -F /dev/mapper/rxc0
  $ sudo mkdir /mnt/rxc0
  $ sudo mount /dev/mapper/rxc0 /mnt/rxc0

Other Device-Mapper specific commands:

  • $ sudo dmsetup status rxc-node
  • $ sudo dmsetup table rxc-node

Additional Information