You can use the Redis – Benchmark tool to test the performance of Redis.

Single test

The Docker and Host

Compare the performance difference between Redis in Docker and Host. H refers to Host and C refers to Container.

Parameters:

  • Requests: 100 _000
  • Clients: 50
  • Payload: 3
  • Keey Alive: 1
  • Save: 900 1; 300 10; 60, 10000
  • AOF: no
  • Multi Threads: no
Test H QPS C QPS QPS ratio H Latency C Latency La Ratio
PING_INLINE 174520.06 40112.31 4.35 0.162 1.151 0.140
PING_MBULK 154559.5 42176.30 3.66 0.188 1.092 0.172
SET 174216.03 42194.09 4.12 0.166 1.094 0.151
GET 171821.3 42301.18 4.06 0.160 1.091 0.146
INCR 194552.53 40799.68 4.76 0.146 1.134 0.128
LPUSH 188679.25 41152.26 4.58 0.148 1.125 0.131
RPUSH 190476.2 41169.21 4.62 0.147 1.123 0.130
LPOP 176991.16 41017.23 4.31 0.157 1.128 0.139
RPOP 176991.16 41237.11 4.29 0.155 1.123 0.138
SADD 181488.2 40833.00 4.44 0.151 1.131 0.133
HSET 165016.5 40600.89 4.06 0.165 1.134 0.145
SPOP 176678.45 41407.87 4.26 0.154 1.114 0.138
ZADD 214132.77 40633.89 5.26 0.133 1.135 0.117
ZPOPMIN 173310.22 41390.73 4.18 0.161 1.116 0.144
LPUSH 158730.16 40650.41 3.90 0.184 1.137 0.161
LRANGE_100 93196.65 34094.78 2.73 0.304 1.288 0.236
LRANGE_300 30432.14 21427.04 1.42 0.897 1.726 0.519
LRANGE_500 21399.53 15850.37 1.35 1.264 2.136 0.591
LRANGE_600 18726.59 14269.41 1.31 1.542 2.284 0.675
MSET 138121.55 38565.37 3.58 0.312 1.203 0.259
Avg 3.76 0.220

As you can see, the difference between the container and the real machine is quite obvious, but it’s not a real machine yet because I’m using WSL2, which is also a virtual machine. So it’s really “WSL2 + Docker” versus “WSL2”.

Why not update the test results on real Windows machines? It’s because Redis doesn’t perform particularly well in Win, it’s almost twice as fast as Docker, which is worse than WSL.

Rdb switch comparison

Compare the speed difference between Rdb on and off.

Parameters:

  • Requests: 100 _000
  • Clients: 50
  • Payload: 3
  • Keey Alive: 1
  • Save:
    • ON:900 1; 300 10; 60, 10000
    • OFF:""
  • AOF: no
  • Multi Threads: no
Test No QPS QPS QPS ratio No Latency Latency La Ratio
PING_INLINE 37509.38 36818.85 1.018 1.242 1.269 0.978
PING_MBULK 38022.81 37778.62 1.006 1.223 1.229 0.995
SET 37664.79 37147.11 1.013 1.236 1.252 0.987
GET 37050.76 37257.82 0.994 1.258 1.247 1.008
INCR 36995.93 36995.93 1.000 1.258 1.254 1.003
LPUSH 35549.23 37119.52 0.957 1.312 1.255 1.045
RPUSH 36523.01 36656.89 0.996 1.277 1.269 1.006
LPOP 35893.75 35919.54 0.999 1.299 1.296 1.002
RPOP 36630.04 36549.71 1.002 1.275 1.273 1.001
SADD 36429.88 36913.99 0.986 1.278 1.259 1.015
HSET 36114.12 36643.46 0.985 1.288 1.268 1.015
SPOP 36764.71 36710.72 1.001 1.267 1.266 1.000
ZADD 36179.45 35932.45 1.006 1.283 1.294 0.991
ZPOPMIN 36643.46 36710.72 0.998 1.268 1.266 1.001
LPUSH 36205.65 36205.65 1.000 1.285 1.282 1.002
LRANGE_100 29841.84 30039.05 0.993 1.491 1.478 1.008
LRANGE_300 20242.91 20088.39 1.007 1.916 1.909 1.003
LRANGE_500 15128.59 15239.26 0.992 2.362 2.352 1.004
LRANGE_600 13575.89 13676.15 0.992 2.521 2.511 1.003
MSET 34806.82 34566.2 1.006 1.341 1.351 0.992
Avg 0.998 1.003

As you can see, the speed difference between the two is not significant because Rdb is not an instant snapshot in the first place, so there is little performance impact.

AOF switch comparison

Compare the difference between AOF on and off, and the different modes.

  • QPS contrast:

    TEST OFF NO Every Second Always
    PING_INLINE 35129.63 37835.79 37678.97 34700.54
    PING_MBULK 36331.93 36865.00 36960.38 34499.41
    SET 36683.79 30829.94 31098.4 2778.4
    GET 36568.42 34616.45 36662.27 37064.49
    INCR 36435.18 28082.00 31293.03 5991.11
    LPUSH 35803.79 27997.09 30644.77 3421.54
    RPUSH 35270.88 27942.33 30994.3 2879.06
    LPOP 32731.08 27311.96 30929.11 2377.05
    RPOP 32632.82 27783.95 31135.19 2792.09
    SADD 32918.56 33200.53 36480.37 37103
    HSET 29647.2 28494.90 30847.06 6031.22
    SPOP 32754.67 34698.12 36710.72 37094.74
    ZADD 32356.18 35714.29 36093.27 35844.86
    ZPOPMIN 32877.43 36129.78 36659.58 36648.83
    LPUSH 33064.41 30415.48 30723.85 6216.04
    LRANGE_100 27886.22 29463.76 29721.21 30558.61
    LRANGE_300 19910.01 19972.84 19861.76 20112.63
    LRANGE_500 15160.7 15237.86 14933.4 15082.5
    LRANGE_600 13756.67 13838.92 13340.45 13512.05
    MSET 33824.92 27719.26 28282.14 5615.39
  • Time delay

    TEST OFF NO Every Second Always
    PING_INLINE 1.324 1.231 1.238 1.342
    PING_MBULK 1.278 1.261 1.259 1.346
    SET 1.269 1.522 1.509 17.893
    GET 1.272 1.343 1.27 1.255
    INCR 1.276 1.667 1.5 8.238
    LPUSH 1.3 1.673 1.532 14.494
    RPUSH 1.32 1.677 1.514 17.247
    LPOP 1.421 1.715 1.516 20.934
    RPOP 1.426 1.688 1.507 17.781
    SADD 1.411 1.399 1.275 1.253
    HSET 1.565 1.644 1.519 8.189
    SPOP 1.417 1.338 1.267 1.255
    ZADD 1.435 1.302 1.289 1.299
    ZPOPMIN 1.411 1.285 1.267 1.268
    LPUSH 1.407 1.542 1.526 7.942
    LRANGE_100 1.596 1.511 1.496 1.455
    LRANGE_300 1.953 1.941 1.942 1.918
    LRANGE_500 2.38 2.378 2.391 2.375
    LRANGE_600 2.529 2.523 2.558 2.538
    MSET 1.381 1.704 1.671 8.799

You can see that the performance of Every Second mode is close to that of AOF, but the performance of NO mode is worse than that of Every Second, which is quite surprising to me. It may be because the system flush mechanism of the container is slightly different, and we will test the timing to verify the comparison.

TODO: Verifies that the no mode is worse than every second.

As you can see, the Always mode is so deadly that it can even compete with transactional databases for concurrency that it is highly discouraged.