Running Redis on Raspberry PI Zeros

In the past months I replaced a lot of Raspberry Pi Zero Ws with Raspberry Picos running ESPHome. What could I use these extra Zeros for now? For another ongoing project I need a Redis as broker in my local network. I could use one of the Zeros for that, but are they fast enough?

First we need Docker to run the armv6 version of Redis. To install Docker I chose the convenience solution which when looking at the script is doing the same as the manual version above on the same site.

Install Docker:

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

To simplify the Docker command, we use Docker Compose and change the command to actually store data on disk, add a volume and expose the Redis port.

services:
  redis:
    image: redis:7-alpine
    ports:
      - '6379:6379'
    command: redis-server --save 60 1 --loglevel warning --requirepass some-password
    volumes:
      - /home/pi/redis-data:/data

Finally start the container:

mkdir /home/pi/redis-data
sudo docker compose up -d

I setup this on two Raspberry Pi Zero Ws and one Raspberry Pi Zero 2W to compare to. The actual benchmark was run on my notebook in the same network:

docker run --rm redis redis-benchmark -h <IPADRESS> -a some-password -t set,get -r 10000 -n 100000 -q

The settings are: Only test "set" and "get" and use 10000 different random keys and not use only one key. Do this 100000 times.

Runs:

run

Raspberry

SET

GET

1st run

Zero W A

SET: 680.38 requests per second, p50=66.495 msec

GET: 692.57 requests per second, p50=65.119 msec

2nd run

Zero W A

SET: 716.61 requests per second, p50=67.647 msec

GET: 724.76 requests per second, p50=66.815 msec

3rd run

zero W A

SET: 710.87 requests per second, p50=67.519 msec

GET: 724.68 requests per second, p50=66.751 msec

1st run

zero W B

SET: 723.24 requests per second, p50=65.855 msec

GET: 730.49 requests per second, p50=64.959 msec

2nd run

zero W B

SET: 703.07 requests per second, p50=68.607 msec

GET: 719.88 requests per second, p50=67.711 msec

1st run

zero 2W

SET: 4020.59 requests per second, p50=11.319 msec

GET: 4209.99 requests per second, p50=11.287 msec

2nd run

zero 2W

SET: 4068.68 requests per second, p50=11.231 msec

GET: 4254.41 requests per second, p50=11.231 msec


CPU on the Zero 1Ws is between 30% and 40% for the Redis process while the benchmark is happening. The Zero 2W is around 40% CPU too, but it is using all 4 CPUs. As seen in the benchmark the Zero 2W is more than 5x faster than the Zero 1W. I still plan to use a spare Zero 1W for Redis. When the performance is not enough I still can replace it with a Zero 2W.