一、Redis单线程 vs 多线程(1、 Redis single thread vs multi thread)

Redis的版本很多3.x、4.x、6.x,版本不同架构也是不同的,不限定版本问是否单线程也不太严谨。

1、版本3.x ,redis是单线程。

2、版本4.x,严格意义来说也不是单线程,而是负责处理客户端请求的线程是单线程,但是开始加了点多线程的东西(异步删除)。——貌似

3、最新版本的6.0.x后,告别了大家印象中的单线程,用一种全新的多线程来解决问题。

Redis单线程的优势:

1、数据结构简单。

2、避免锁的开销和上下文切换。

3、可以有很高的Qps。

————————

There are many versions of redis 3 x、4. x、6. x. Different versions have different architectures. There is no limit to the version. It is not rigorous to ask whether a single thread is required.

1. Version 3 x. Redis is single threaded.

2. Version 4 x. Strictly speaking, it is not a single thread, but the thread responsible for processing client requests is a single thread, but it starts to add something multi-threaded (asynchronous deletion)—— seemingly

3. The latest version of 6.0 After X, we bid farewell to the impression of single thread and use a new multi thread to solve the problem.

Advantages of redis single thread:

1. Simple data structure.

2. Avoid lock overhead and context switching.

3. Can have very high QPS.