Implementation of PHPlimitrequest bucket leakage

Source: Internet
Author: User
PHPlimitrequest bucket leakage has been attacked by friends in recent days, leading to CDN bandwidth spikes and some page requests have also been affected. In addition to Nginx ngx_http_limit_req_module, some optimizations are also required at the PHP level to avoid the impact of Nginx 503 error on user experience.

After a simple discussion, a solution is provided: when the number of requests per second (based on each session sid) exceeds 3, the verification code is displayed and access to all pages is prohibited, the verification code is entered successfully.

When a user requests a verification code, the following verification page is displayed:

To reduce code changes, we add a parent class for each front-end controller class to control the number of requests at the program entry. the code snippet is as follows:

Finally, we will show you the results :)

After the release, the response of the verification code page is faster, the number of requests increases slightly, the total bandwidth usage is reduced by nearly 10 times, and the traffic is also significantly reduced.

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.