Redis-based single-threaded multi-thread

What is single-threaded/multi-threaded, and what is single-core multi-core

The code written in the program is still executed on the basis of computer hardware. The so-called single-threaded multi-threading is equivalent to when the cpu is working. In order to make full use of the power of the cpu, more tasks are given to the cpu, such as Monkey King. Fighting monsters alone, if you pluck their hair directly to form a group of monkeys and grandchildren, fighting monsters together will be more efficient.
A single core is a cpu core, and a multi-core is multiple cpu cores (unit groups)

Life story

Single core: living alone
Multi-core: married couple living together
Single thread: washing clothes – cooking – sweeping the floor
Multi thread: washing clothes and cooking, or sweeping the floor
Single core single thread: washing clothes alone – cooking – sweeping the floorSerial (step by step)
Single-core and multi-threaded: One person may be cleaning the floor while washing clothes and cooking Concurrency (seems to be at the same time, but internally, it's step by step)
Multi-core single thread: one person
washes clothes-cooks-sweeps the floor Multi-core multi thread: two people wash clothes and the other cookParallel (true simultaneous)

OK, I understand single-core, anyway, it’s just one person, no matter whether it is single-threaded or multi-threaded, I do the work by myself, but single-threaded is doing one by one, and multi-threaded seems to be doing multiple at the same time.
noteOn the surface, multi-threading seems to be doing things at the same time. In fact, there is a time sequence at the micro level. It may only be at the nanosecond level. Just like when cooking and sweeping the floor, the brain will still send instructions one by one. Manually, the feet are on. Move it like this, even though it looks like cooking and sweeping are going on.

What about multi-core?
Multi-core and multi-threading are performed at the same time in a true sense, and multiple threads are performed at the same time, but the cpu still allocates time instructions serially in order.

Why does Redis use single thread

Why did you do this?
First of all, single-threaded multi-threading improves the utilization of cpu, while redis is based on memory, CPU will not become a bottleneck, as you know above, and single-core multi-threading involves cpu switching context, which is a resource and time consuming process.
So single thread avoids these and can be faster. It must be used to process the request with this single thread.
In addition, the command is safe with a single thread, and the data is at ease.

What about multi-core?
Isn't it equivalent to one person working and the other quitting?
We can open two redis service instances, this will not be solved, it is both single-threaded and multi-core;

Is Redis completely single-threaded?

The answer is no; the
redis module has four parts

Insert picture description here

Because the consumption of the file event dispatcher queue is single-threaded, redis is called the single-threaded model
However, in the event handler isMultithreadingof;