What is the maximum concurrency of redis?
What this article shares to you is about the maximum concurrency of redis. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
Concurrency problems in redis
Redis has been used as a cache for a long time. Redis runs as a single process, and commands are executed one after another. I always thought that there would be no concurrency problem. I didn't realize it until I saw the relevant information today.
Examples of specific problems
There is a key, suppose the name is myNum, which stores Arabic numerals, suppose the current value is 1, there are multiple connections to operate on myNum, this time there will be concurrency problems. Suppose there are two connections linkA and linkB, both of which do the following, take out the value of myNum, + 1, and then save it back to see the following interaction:
LinkA get myNum = > 1linkB get myNum = > 1linkA set muNum = > 2linkB set myNum = > 2
After the operation, the result may be 2, which is not consistent with our expectation of 3.
Let's look at a specific example: