Redis provides a benchmarking tool called redis-benchmark
for testing the performance of common redis commands. The benchmarks in this blog are run on below configuration.
- Model - MacBook Air 2019
- Processor - 1.6 GHz Dual-Core Intel Core i5
- Memory - 8 GB 2133 MHz LPDDR3
- Client - redis-benchmark
- Server - localhost:6379
- Both client and server are running on the same machine
redis-benchmark
runs the tests over 100000 commands by default. You can tweak the numbers as required.
If you haven’t already, do checkout this article for more details on redis-benchmark
tool.
$redis-benchmark -q
PING_INLINE: 23860.65 requests per second
PING_BULK: 21008.40 requests per second
SET: 19124.12 requests per second
GET: 19782.39 requests per second
INCR: 20833.33 requests per second
LPUSH: 22999.08 requests per second
RPUSH: 25316.46 requests per second
LPOP: 24685.26 requests per second
RPOP: 22993.79 requests per second
SADD: 22016.73 requests per second
HSET: 22286.61 requests per second
SPOP: 26688.02 requests per second
LPUSH (needed to benchmark LRANGE): 21767.52 requests per second
LRANGE_100 (first 100 elements): 9999.00 requests per second
LRANGE_300 (first 300 elements): 4682.31 requests per second
LRANGE_500 (first 450 elements): 3155.77 requests per second
LRANGE_600 (first 600 elements): 2412.25 requests per second
MSET (10 keys): 13802.62 requests per second
So, we could do 19k reqs/sec with redis get command.
Let’s set some keys to benchmark redis mget
set hash1_key1 "The golden rule of a useful benchmark is not to compare apples to oranges"
set hash2_key2 "The golden rule of a useful benchmark is not to compare apples to oranges"
set hash3_key3 "The golden rule of a useful benchmark is not to compare apples to oranges"
$redis-benchmark mget hash1_key1 hash2_key2 hash3_key3 ... (1000 keys)
100000 requests completed in 113.54 seconds
50 parallel clients
3 bytes payload
keep alive: 1
0.00% <= 1 milliseconds
0.06% <= 2 milliseconds
15.38% <= 44 milliseconds
20.01% <= 45 milliseconds
25.82% <= 46 milliseconds
32.60% <= 47 milliseconds
40.24% <= 48 milliseconds
48.40% <= 49 milliseconds
56.21% <= 50 milliseconds
63.03% <= 51 milliseconds
68.34% <= 52 milliseconds
72.26% <= 53 milliseconds
75.10% <= 54 milliseconds
90.14% <= 78 milliseconds
95.77% <= 83 milliseconds
99.99% <= 234 milliseconds
100.00% <= 235 milliseconds
100.00% <= 236 milliseconds
100.00% <= 237 milliseconds
100.00% <= 241 milliseconds
880.72 requests per second
So, we were able to fetch 880*1000 = 880000 keys/sec via mget
compared to 19k keys/sec with get
.