Here I will just talk about how redis controls concurrency
redis mainly uses the three functions of
For example, I have a rush purchase demand here. Only 200 pieces of a product are run. The general idea is as follows
Check the redis message queue length every time to see if it has exceeded or = 200
So we have a separate program on the back end to do queue processing. If the number is too large, no further processing will be performed.
Of course. Users that have been queued for this frontend. You can't tell people you've got it. He should be asked to check the results after 5 minutes.
The quantity processed in this way will not be exceeded. Of course, if the concurrency is too large, you can specifically look for a concurrency processing architecture.
If you require a friendly user experience, use socket to obtain the back-end processing results and tell the user whether they have grabbed it. Redis processing is quite fast, so you don’t have to worry about users waiting too long.
The above introduces PHP redis concurrency control, including redis content. I hope it will be helpful to friends who are interested in PHP tutorials.