The role of redis and why redis is so fast

1 The role of redis:

  Using redis for caching, redis can be used as database, cache and message middleware.

How redis does persistence: The data set can be exported to disk (snapshot) at regular intervals, or appended to the command log, and the executed write command will be copied to the hard disk when the write command is executed.

Why is redis fast: Redis stores data in memory, and when reading and writing data, it is not limited by the speed of disk I/O, so it is extremely fast.

1 Completely based on memory, most requests are pure memory operations, very fast. 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 is specially designed.

3 Using a single thread, unnecessary context switching and race conditions are avoided, and there is no cpu consumption due to switching caused by multi-threading or multi-threading. There is no need to consider various lock issues. deadlock possible

resulting in performance consumption;

4 Use multiple I/O multiplexing model, non-blocking io;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325076466&siteId=291194637