Home  >  Article  >  Database  >  What does redis single thread mean?

What does redis single thread mean?

(*-*)浩
(*-*)浩Original
2019-11-02 13:59:352621browse

What does redis single thread mean?

The official FAQ states that because Redis is a memory-based operation, the CPU is not the bottleneck of Redis. The bottleneck of Redis is most likely the size of the machine memory or the network bandwidth. Since single-threading is easy to implement and the CPU will not become a bottleneck, it is logical to adopt the single-threaded solution (Recommended learning: Redis video tutorial)

What does redis single thread mean?See By this point, you may cry! I thought there would be some major technical points that make Redis so fast using a single thread, but I didn't expect an official answer that seemed to fool us! However, we can already clearly explain why Redis is so fast, and precisely because it is already fast in single-threaded mode, there is no need to use multi-threading!

However, our single-threaded approach cannot take advantage of multi-core CPU performance, but we can improve it by opening multiple Redis instances on a single machine!

Warning 1:The single thread we have been emphasizing here only has one thread to process our network requests. When a formal Redis Server is running, there must be more than one thread. It’s a thread, everyone needs to pay clear attention here! For example, when Redis is persisted, it will be executed as a sub-process or sub-thread (the specific sub-thread or sub-process needs to be studied in depth by the reader); for example, I checked the Redis process on the test server weapon, and then found the thread under the process:

What does redis single thread mean?

The "-T" parameter of the ps command indicates Show threads, possibly with SPID column. The "SID" column indicates the thread ID, and the "CMD" column Thread name is shown.

Warning 2: The last paragraph in the FAQ in the above picture states that multi-threading will be supported starting from Redis 4.0 version, but only multi-threading is performed on certain operations. operation! Therefore, whether this article will still be single-threaded in future versions requires readers to verify!

The above is the detailed content of What does redis single thread mean?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:How to use redis in javaNext article:How to use redis in java