PHP handles high concurrency issues

Source: Internet
Author: User

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.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.