My basic understanding is that all operations in Redis are single threaded. In Redis-6 there is multi-threaded I/O.. I'm just curious what advantage this has if all the I/O threads still need to wait on the single thread that does all the querying? I was hoping someone could provide some example work loads that would illustrate the advantages or disadvantages.
My basic understanding is that all operations in Redis are single threaded.
NO. Even before Redis 6, there're some background threads, e.g. background saving, unlinking keys asynchronously.
I'm just curious what advantage this has if all the I/O threads still need to wait on the single thread that does all the querying?
Before Redis 6, Redis processes a request with 4 steps in serial (in a single thread):
Before it finishes these 4 steps, Redis cannot process other requests, even if there're some requests ready for reading (step 1). And normally writing the response to socket (step 4) is slow, so if we can do the write operation in another IO thread (configuration: io-threads
), Redis can process more requests, and be faster.
Also you can set Redis to run step 1 and 2 in another IO thread (configuration: io-threads-do-reads
), however, the Redis team claims that normally it doesn't help much (Usually threading reads doesn't help much. -- quoted from redis.conf).
NOTE: since step 3 is always running in a single thread, Redis operations are still guaranteed to be atomic.
someone could provide some example work loads that would illustrate the advantages or disadvantages.
If you want to test the Redis speedup using redis-benchmark, make sure you also run the benchmark itself in threaded mode, using the --threads option to match the number of Redis theads, otherwise you'll not be able to notice the improvements. -- quoted from redis.conf
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With