Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Redis SET performance better than GET?

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 typically one would expect that memory writes are somewhat slower than reads, e.g. considering that SETs need to allocate memory prior to being able to write a value.

Can someone explain why SET is faster than GET?

like image 496
miraculixx Avatar asked Jan 30 '13 09:01

miraculixx


People also ask

Does Redis improve performance?

Redis supports pipelining, so it is possible to send multiple commands at once, a feature often exploited by real world applications. Redis pipelining is able to dramatically improve the number of operations per second a server is able do deliver. Using pipelining results in a significant increase in performance.

Why is Redis faster?

Redis is a RAM-based data store. RAM access is at least 1000 times faster than random disk access. 2. Redis leverages IO multiplexing and single-threaded execution loop for execution efficiency.

How fast is Redis set?

According to this run of memtier_benchmark , our Redis server can execute about 90 thousand operations per second in a 1:10 SET / GET ratio. It's important to note that each benchmark tool has its own algorithm for performance testing and data presentation.

How much faster is Redis?

The general answer is that Redis 10 - 30% faster when the data set fits within working memory of a single machine.


Video Answer


1 Answers

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.

like image 57
antirez Avatar answered Oct 05 '22 17:10

antirez