Home > Database > Redis > body text

Why is redis so fast

藏色散人
Release: 2019-06-10 10:52:43
Original
2751 people have browsed it

Redis is a K-K memory database written in ANSI C language, with excellent performance, network support, and persistence, and provides APIs in multiple languages. Its commonly used types are mainly String, List, Hash, Set, and ZSet.

Why is redis so fast

Why is redis so fast?

1. Completely based on memory, most requests are pure memory operations, very fast. The data is stored in memory, similar to HashMap. The advantage of HashMap is that the time complexity of search and operation is O(1);

2. The data structure is simple, and the data operation is also simple. The data structure in Redis It is specially designed;

3. It uses a single thread to avoid unnecessary context switching and competition conditions. There is no switching caused by multi-process or multi-threading to consume the CPU, and there is no need to consider various locks. There is no problem of locking and releasing locks, and there is no performance consumption caused by possible deadlocks;

4. Use multi-channel I/O multiplexing model, non-blocking IO;

5. The underlying models used are different, the underlying implementation methods and the application protocols for communication with the client are different. Redis directly builds the VM mechanism by itself, because if the general system calls system functions, it will waste a certain amount of time. Move and request;

The internal implementation uses epoll, using a simple event framework implemented by epoll itself. Read, write, close, and connect in epoll are all converted into events, and then use the multiplexing feature of epoll to never waste any time on io.

For more Redis technical articles, please visit the redis usage tutorial column!

The above is the detailed content of Why is redis so fast. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template