Single threading and high performance of Redis


Is Redis single threaded?

Single-threading of Redis mainly means that the network IO and key-value pair reading and writing of Redis are completed by one thread, which is also the main process of Redis to provide key-value storage service externally. But other Redis functions, such as persistence, asynchronous deletion, and cluster data synchronization, are actually performed by additional threads.

Why is Redis single thread so fast?

Because all of its data is in memory, all of its operations are memory-level operations, and single-threading avoids the switching performance cost of multithreading. Because Redis is single-threaded, use Redis directives with caution. Use directives that are time-consuming (such as keys) with caution, as they can cause Redis to stall.

How does Redis single thread handle so many concurrent client connections?

IO multiplexing for Redis: Redis uses ePoll to implement IO multiplexing by putting connection information and events into queues, which in turn are placed into file event dispatchers, which distribute events to event handlers.

 

 

# check the maximum number of connections supported by Redis.

# maxclients 10000 127.0.0.1:6379> CONFIG GET maxclients    

##1) “maxclients”    

# # 2) “10000”