In a highly concurrent business, the accompanying problem is how to handle the user's request accurately and without error, and to give a quick response is the key, for the database in concurrency will cause pressure surges, the data may not be unified problem. So the design of the program is critical. Main scenes such as: Rob tickets, seconds to kill goods, etc...
One, using Memcacheq Message Queuing
Queue FIFO storage allows us to set the number of seconds to kill the amount of goods as the upper limit, and in the cache, when the user instantaneous request server to determine whether the current number of requests is greater than the total amount of goods, greater than the jump into the static failure page, if compliant then enter the next process of the program.
Second, using memcached cache current limit
By the user request time-limited processing to reduce the pressure on the database, and to provide reliable data, using two cache to control the request to enter the data, such as setting Key1 to True, then the user can grab and enter the process after entering, the value is changed to False, Other requests cannot be entered (queued, and recursively called), and the current request is processed to restore its value, depending on the requirements.
Third, the distributed situation
If it is a distributed server cluster, the average number of goods on each server, the same is judged whether the requirements, as the scheme
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
The above describes the PHP processing of high concurrency issues, including the content, I hope that the PHP tutorial interested in a friend to help.