Redis get
vs. mget
Benchmark
0. Background
Scripts
#!/bin/bash
key="testkey"
value="testvalue"
int=0
while (($int <= 1024)); do
echo -e $key$int $value
redis-cli set $key$int $value
let "int++"
done
#!/bin/bash
int=0
keys=""
while (($int < 64)); do
keys="$keys","'testkey$int'"
let "int++"
done
redis-benchmark -n 100000 script load "redis.call('mget'$keys)"
System Info
[p1gd0g@p1gd0g-pc ~]$ screenfetch
██████████████████ ████████ p1gd0g@p1gd0g-pc
██████████████████ ████████ OS: Manjaro 19.0.2 Kyria
██████████████████ ████████ Kernel: x86_64 Linux 5.4.31-1-MANJARO
██████████████████ ████████ Uptime: 1h 1m
████████ ████████ Packages: 1224
████████ ████████ ████████ Shell: bash
████████ ████████ ████████ Resolution: 1920x1080
████████ ████████ ████████ DE: GNOME 3.36.1
████████ ████████ ████████ WM: Mutter
████████ ████████ ████████ WM Theme: Matcha-sea
████████ ████████ ████████ GTK Theme: Matcha-sea [GTK2/3]
████████ ████████ ████████ Icon Theme: Papirus-Dark-Maia
████████ ████████ ████████ Font: Noto Sans 11
████████ ████████ ████████ Disk: 41G / 473G (10%)
CPU: AMD Ryzen 5 3550H with Radeon Vega Mobile Gfx @ 8x 2.1GHz
GPU: AMD RAVEN (DRM 3.35.0, 5.4.31-1-MANJARO, LLVM 9.0.1)
RAM: 2237MiB / 6956MiB
Redis version
Redis server v=5.0.8 sha=00000000:0 malloc=jemalloc-5.2.1 bits=64 build=b2bf869b5247fdeb
1. get
vs. mget
redis-benchmark -n 100000 script load "redis.call('get', 'testkey0')"
====== script load redis.call('get', 'testkey0') ======
100000 requests completed in 0.65 seconds
50 parallel clients
3 bytes payload
keep alive: 1
99.98% <= 1 milliseconds
100.00% <= 1 milliseconds
152905.20 requests per second
redis-benchmark -n 100000 script load "redis.call('mget', 'testkey0')"
====== script load redis.call('mget', 'testkey0') ======
100000 requests completed in 0.66 seconds
50 parallel clients
3 bytes payload
keep alive: 1
99.99% <= 1 milliseconds
100.00% <= 1 milliseconds
151975.69 requests per second
cmd
RPS(9 bytes)
RPS(18 bytes)
RPS(36 bytes)
RPS(72 bytes)
RPS(144 bytes)
RPS(288 bytes)
RPS(576 bytes)
RPS(1152 bytes)
RPS(2304 bytes)
get
152905
152207
151285
156494.52
148148.14
148588.42
150602.42
149700.61
144508.67
mget
(1)
151975
152207
141242
149253.73
151975.69
152671.77
145985.41
145348.83
152439.02
mget
(2)
146842
148809
152207
150602.42
152905.20
147929.00
147492.62
152439.02
150829.56
mget
(4)
151745
152439
154798
150829.56
149700.61
152439.02
151975.69
149253.73
149031.30
mget
(8)
148148
148367
144717
150602.42
152905.20
142045.45
147058.83
151057.41
144092.22
mget
(16)
155763
147275
158478
151745.08
152905.20
151057.41
148148.14
152905.20
149700.61
mget
(32)
150375
151057
156739
159489.64
147058.83
154559.50
151745.08
149925.03
151057.41
mget
(64)
154559
143678
145985
147275.41
145560.41
152207.00
151745.08
151285.92
144927.53
mget
(128)
124688
130208
125156
131233.59
127226.46
123915.74
129032.27
123456.79
124223.60
mget
(256)
14714
14952
15130
14744.91
14677.82
15003.75
14974.54
15117.16
14988.01
mget
(512)
13455
13904
13925
13892.75
14046.92
13886.96
13804.53
13958.68
13976.24
mget
(1024)
11825
12051
12032
11748.12
11526.05
11923.21
12003.36
12195.12
12105.07
2. set
vs. mset
cmd
RPS
set
152671
mset
(1)
151057
mset
(2)
149476
mset
(4)
147710
mset
(8)
145772
mset
(16)
145985
mset
(32)
145137
mset
(64)
122549
mset
(128)
15820
mset
(256)
14524
mset
(512)
12751
mset
(1024)
9726
3. What happended if keys=248?
keys
RPS
mget
(128)
124688
mget
(192)
110497
mget
(224)
99502
mget
(240)
95147
mget
(244)
94966
mget
(246)
94607
mget
(247)
93896
mget
(248)
14945
mget
(256)
14714