Architecture

The Redis server is a single-threaded program written in C, which uses epoll/kqueue to enable asynchronous IO. You might wonder whether a single-threaded system can scale, but oh boy does Redis scale! The key insight here is that for storage systems, the CPU is rarely the bottleneck—most of the time is spent in I/O (network or storage). Kernel constructs such as epoll/kqueue allow application programs to initiate I/O and not get blocked by the operation. This way, a single thread can multiplex a lot of I/O operations.

The single-threaded architecture also provides one key benefit—no race conditions. Since there aren't multiple threads, there is no need for synchronization. This means that there are no lock contentions or nasty deadlocks.

The performance of the architecture can be seen from the benchmark shared by Jak Sprats on the Redis group (http://nosql.mypopescu.com/post/1078083613/redis-a-concurrency-benchmark):

The x axis is the number of concurrent requests and the y axis is the performance in terms of QPS. The benchmark shows a performance of 90,000 QPS with 26,000 concurrent requests!

More benchmarks are detailed here: https://redis.io/topics/benchmarks.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset