Supercharged caching on Raspberry PI 4 with cachegrand!

raspberrypi4 ARM aarch64 green sbc


Cachegrand is a modern open-source key-value store platform that provides a faster and more efficient alternative to Redis. In this blog post, we will introduce cachegrand, explain why it is better than Redis, and provide step-by-step instructions on how to set up and run cachegrand on a Raspberry Pi 4 using Docker.

Using ARM CPUs for Running Key-Value Stores or Caches

Using ARM CPUs such as Raspberry Pi 4 for running key-value stores like cachegrand has advantages over traditional x86 CPUs. ARM devices are usually more energy-efficient and cost-effective than x86 devices, and they also have lower heat dissipation and noise levels which may be desirable for some applications.

However, using ARM devices also has some drawbacks compared to x86 devices, such as less memory capacity and bandwidth, and less software compatibility or support. Therefore, whether using ARM devices for running key-value stores like cachegrand is a good choice depends on your specific needs and preferences. You should consider factors such as performance requirements, budget constraints, power consumption levels, environmental conditions, etc. before making a decision.

Why Not Just Run Redis on a Raspberry Pi 4?

There are several reasons why you might want to use cachegrand over Redis:

  • cachegrand can use all the CPU cores of the Raspberry Pi 4, providing much better performance than Redis.
  • cachegrand can leverage modern hardware features such as large memory pages, huge TLB caches, SIMD (NEON) instructions, etc., which can improve efficiency and scalability compared to Redis.
  • Although the supported command set is limited, cachegrand can act as a drop-in replacement for Redis without requiring any code changes or configuration changes.

Prerequisites to Run cachegrand on a Raspberry Pi 4 Using Docker

To run cachegrand on a Raspberry Pi 4 using Docker, you will need a Raspberry Pi 4 with:

  • Raspbian OS 64 Bit
  • The irqbalance service for performance reasons
  • Docker

It is mandatory to use a 64-bit operating system as cachegrand is built for modern hardware and will not run on the 32-bit version of the OS.

Install Docker on the Raspberry Pi 4

If you have already Docker installed feel free to skip this section, otherwise you can follow these instructions to install Docker:

  1. Update your system packages:
sudo apt update
sudo apt upgrade -y
  1. Install Docker using the Docker official installation script:
curl -sSL | sh
  1. Allow a non-root user (such as pi) to execute Docker commands using this command:
sudo usermod -aG docker pi
  1. Login again or use newgrp to get access to the docker group, for example
newgrp docker
  1. Check that docker is up and running with
docker run --rm hello-world

Setup the irqbalance service

The irqbalance service is a daemon that helps balance the CPU load generated by interrupts across all of a system's CPUs. To enable irqbalance on Raspbian OS 64-bit, you need to follow these steps:

  1. Install irqbalance using this command:
sudo apt install irqbalance
  1. Enable irqbalance service using this command:
sudo systemctl enable irqbalance
  1. Start irqbalance service using this command:
sudo systemctl start irqbalance
  1. Check the status of irqbalance service using this command:
sudo systemctl status irqbalance

If everything works fine, you should see a message like this:

● irqbalance.service - LSB: daemon to balance interrupts for SMP systems
   Loaded: loaded (/etc/init.d/irqbalance; generated)
   Active: active (running) since ...

Run cachegrand via docker:

  1. Pull the cachegrand image:
docker pull cachegrand/cachegrand-server:latest
  1. Run the cachegrand container:
docker run \
  -d \
  --network=host \
  --ulimit memlock=-1:-1 \
  --ulimit nofile=262144:262144 \
  -p 6379:6379 \
  -p 6380:6380 \
  --name cachegrand \

This will start a detached container named cachegrand that exposes port 6379 (the default port for Redis) and the port 6380, for TLS, on your Raspberry Pi 4. You can then connect to cachegrand using any client that supports Redis protocol.

For performance reasons the network mode is set to host.

  1. Test using redis-cli
redis-cli SET hello world
redis-cli GET hello

If the redis-cli is not available on the system, it's possible to leverage docker

docker run --rm -it --network=host redis redis-cli SET hello world
docker run --rm -it --network=host redis redis-cli GET hello

Stop or remove the container

  1. Stop the cachegrand container:
docker stop cachegrand
  1. Remove the cachegrand container:
docker rm cachegrand

Personalize the config file

  1. First, you need to download the default configuration file from GitHub using this command:
wget && mv cachegrand.yaml.skel cachegrand.yaml
  1. Once you have downloaded the config file, you can open it using a text editor of your choice, for example you can use nano, vim, etc..
nano cachegrand.conf

Modify the options in the configuration file according to your preferences. You can modify options such as the port number, the log level, the memory limit, the persistence options, etc. Make sure to save the changes to the file after modifying it.

  1. Finally, you need to run cachegrand on your Raspberry Pi 4 using Docker and mount the config file as a volume. You can use this command:
docker run \
  -d \
  --network=host \
  -v /path/to/cachegrand.yaml:/etc/cachegrand/cachegrand.yaml \
  --ulimit memlock=-1:-1 \
  --ulimit nofile=262144:262144 \
  -p 6379:6379 \
  -p 6380:6380 \
  --name cachegrand \

Just replace /path/to/cachegrand.yaml with the path to where the config file was downloaded.


Cachegrand is a blazing fast Redis alternative that can provide better performance and scalability compared to Redis, especially when running on modern hardware architectures. By leveraging modern hardware features and having a modular design, cachegrand is a promising key-value store platform that can be used for various applications.

Running cachegrand on a Raspberry Pi 4 using Docker can be a great choice for users who are looking for a cost-effective and energy-efficient solution for their key-value store needs. The process of running cachegrand on a Raspberry Pi 4 using Docker is relatively simple and can be personalized to fit the specific needs and preferences of the user by modifying the configuration file.

Its compatibility with Redis and ease of use with Docker make it a great option for developers and users looking to optimize their key-value store solutions. By considering the advantages and drawbacks of using ARM devices and modifying the configuration file to fit your needs, you can take full advantage of cachegrand's capabilities on your Raspberry Pi 4!

avatar Daniele Salvatore Albano

Keep Reading...

New release with ARM support!

avatar Daniele Salvatore Albano