Why is redis so fast?

Alibaba cloud Q & A 2022-02-13 08:06:54 阅读数:502

redis fast

Redis Why so soon? ?




Take the answer 1:

1、 Completely based on memory , Most requests are purely memory operations , Very fast . Data is in memory , Be similar to HashMap,HashMap The advantage is the time complexity of both the lookup and the operation O(1);

2、 The data structure is simple , It's also easy to manipulate data ,Redis The data structure in is specially designed ;

3、 Using single thread , Unnecessary context switches and race conditions are avoided , There is also no switching consumption caused by multiple processes or multiple threads CPU, You don't have to worry about locks , There is no lock release operation , There is no performance penalty due to possible deadlocks ;

4、 Using multiple channels I/O Reuse model , Non blocking IO;

5、 Using the underlying model is different , The underlying implementation and application protocols for communicating with clients are different between them ,Redis Build it yourself VM Mechanism , Because the normal system calls system functions , It's a waste of time moving and requesting ;


copyright:author[Alibaba cloud Q & A],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/02/202202130806528336.html