Redis on Ubuntu - Snap or Apt?
Table of Contents
I noticed Redis is available via both Snap and APT on Ubuntu. There also seems to be a lack of performance comparison out in the wild, so I thought I'd give it a shot. This is part of some research I'm doing into how to effectively use "small" tech stacks in indie projects.
This is a super simple analysis using the redis-benchmark
utility, and throwing the outputs into ChatGPT with the Code Interpreter to analyse.
Disclaimer
Of course, I'm not someone privy to the inner workings of Redis, Snap or APT, and this benchmark might not reflect real-world usage. However I think it's an interesting comparison point to have and I wanted to sate my curiosity.
The benchmarking was conducted on a 1GB RAM, 1 Intel vCPU Digital Ocean droplet. I'm sure results may vary further in different hardware configurations.
The Results
To be honest, I was surprised. I was always under the impression Snap was slower, but it seems it was a bit faster in this scenario. Here's the results across the various tests that redis-benchmark
conducts in a completely stock benchmarking run:
- PING_INLINE: Snap showed a 11.97k higher throughput and a 0.069ms lower average latency.
- PING_MBULK: Snap showed a 12.39k higher throughput and a 0.091ms lower average latency.
- SET: Snap showed a 23.31k higher throughput and a 0.173ms lower average latency.
- GET: Snap showed a 21.34k higher throughput and a 0.145ms lower average latency.
- INCR: Snap showed a 8.36k higher throughput and a 0.047ms lower average latency.
- LPUSH: Snap showed a 16k higher throughput and a 0.098ms lower average latency.
- RPUSH: Snap showed a 15.77k higher throughput and a 0.091ms lower average latency.
- LPOP: Snap showed a 22.09k higher throughput and a 0.057ms lower average latency.
- RPOP: Snap showed a 6.66k lower throughput and a 0.058ms higher average latency.
- SADD: Snap showed a 12.98k lower throughput and a 0.12ms higher average latency.
- HSET: Snap showed a 10.14k lower throughput and a 0.089ms higher average latency.
- SPOP: Snap showed a 2.82k higher throughput and a 0.01ms lower average latency.
- ZADD: Snap showed a 9.63k higher throughput and a 0.061ms lower average latency.
- ZPOPMIN: Snap showed a 1.41k higher throughput with no difference in average latency.
- LPUSH: Snap showed a 5.08k lower throughput and a 0.038ms higher average latency.
- LRANGE_100 (first 100 elements): Snap showed a 5.27k higher throughput and a 0.004ms lower average latency.
- LRANGE_300 (first 300 elements): Snap showed a 0.95k higher throughput and a 0.071ms lower average latency.
- LRANGE_500 (first 500 elements): Snap showed a 2.77k lower throughput and a 0.61ms higher average latency.
- LRANGE_600 (first 600 elements): Snap showed a 0.36k lower throughput and a 0.177ms higher average latency.
- MSET (10 keys): Snap showed a 12.76k higher throughput and a 0.169ms lower average latency.
In general, Redis installed via Snap showed higher throughput and lower average latency for most operations compared to APT. However, in a few cases, the APT installation performed better. For example, for the RPOP
, SADD
, HSET
, LPUSH
, LRANGE_500
, and LRANGE_600
operations, the APT installation showed better performance.
Caveats
By the benchmark documentation's own notes, there are some confounding factors here. For example CPU, RAM speed, and Virtualisation.
Given that there were several operations in which APT Redis performed better, the question becomes: are these operations more important for the average use case in a caching and queue scenario?