Why is Redis SET performance better than GET?

前端 未结 1 1991
名媛妹妹
名媛妹妹 2021-02-07 13:22

According to the Redis benchmarks , Redis can perform 100\'000 SET operations/s, and 80\'000 GET operations/s. Redis being an in-memory DB, this seems surprising because typical

1条回答
  •  孤街浪徒
    2021-02-07 13:57

    Actually this is only an effect that by default you measure more I/O than the actual command execution time. If you start enabling pipelining in the benchmark, it is a bit more the measure of the actual command performance, and the numbers will change:

    $ redis-benchmark -q -n 1000000 -P 32 set foo bar
    set foo bar: 338964.03
    $ redis-benchmark -q -n 1000000 -P 32 get foo
    get foo: 432713.09 requests per second
    

    Now GET is faster :-)

    We should include pipelining in our benchmark doc page.

    EDIT: This is even more evident here:

    redis 127.0.0.1:6379> info commandstats
    # Commandstats
    cmdstat_get:calls=1001568,usec=221845,usec_per_call=0.22
    cmdstat_set:calls=831104,usec=498235,usec_per_call=0.60
    

    This command provides CPU time to serve the request internally, without accounting for I/O. SET is three times slower to process.

    0 讨论(0)
提交回复
热议问题