Redis Should Be Multi-threaded

John Sully
2 min readFeb 26, 2019

--

Redis is a bottleneck in our infrastructure, and a major contributor to our AWS bill (those large memory instances are expensive!). About two months ago we started looking into to ways to make it more efficient. Adding threads was an obvious path to go down, so we found it odd Redis hadn’t already done this long ago.

It turns out this is quite a controversial topic sparking a heated debate on twitter.

Our work has resulted in KeyDB, a multithreaded fork of Redis. Since we now have working code at this point, we thought it would be worthwhile to share our data. Despite our code still being at an early stage the results are extremely encouraging:

At 128 bytes KeyDB has almost 2.5x the throughput

The first chart shows that throughput is more than doubled when multi-thread support is added. However Redis is used not just where throughput is required but also in applications that are highly sensitive to latency. We’ve been able to achieve great results there too:

Latency is cut in half when multi-threading is enabled

For the purposes of our benchmark we are using two m5a.2xlarge instances on AWS. One to run the server, and the other to run our bench-marking tool. We decided upon memtier as our benchmark tool for its ability to generate higher levels of traffic. KeyDB is running with 4 threads, while memtier is set to use 8 threads for all tests. All traffic is within the same AWS Availability Zone using private IPs.

We hope this helps inform the debate surrounding whether multi-thread support should be added to Redis. While the additional complexity to the code is certainly still a concern — there is no question its a big performance improvement.

--

--