The solution of large traffic and high concurrency of PHP website

Source: Internet
Author: User
Tags php website dedicated server

How does a PHP website handle high traffic and concurrency?

First, verify that the server hardware is sufficient to support the current traffic.

Ordinary P4 servers can generally support up to 100,000 geo-IPS per day, if the traffic is larger than this, configure a dedicated server with higher performance.

Otherwise, how to optimize can not completely solve the performance problem.

Second, optimize database access,

The front desk is best completely static, can not access the database at all, but for frequently updated sites, static often does not meet certain features,

Caching technology, which stores dynamic data in a cache file, and the Dynamic Web page calls these files directly without having to access the database.

This caching technique is used extensively by both WordPress and Z-blog.

If you do not want to avoid access to the database, then you can try to optimize the database query SQL to avoid using a SELECT * from such statements, each query only return the results they need to avoid a short period of a large number of SQL queries.

Third prohibition of external hotlinking

External Web site picture or file hotlinking often bring a lot of load pressure, so should strictly restrict the external to their own picture or file hotlinking, fortunately, can now easily through refer to control hotlinking, Apache can be configured to prohibit hotlinking, IIS also has some third-party ISAPI that can implement the same functionality.

To prevent the forgery of Refe code hotlinking, you can add watermarks to the image.

IV control the download of large files

Large file download will occupy a large amount of traffic, and for non-SCSI hard disk, a large number of file downloads will consume CPU, so that the impact of the site is reduced, so try not to provide more than 2M large file download, if you need to provide recommendations to put large files on another server.

V. Use different hosts to divert the main flow

Put the files on different hosts, provide different images for users to download, such as if you think the RSS files occupy a large amount of traffic, then use FeedBurner or Feedsky and other services to put the RSS output on other hosts, so that others access to the traffic pressure is mostly concentrated in Freedburner Host, RSS doesn't take up too much resources.

Sixth use flow analysis statistics software

On the site to install a traffic analysis statistics software, you can immediately know those places consume a lot of traffic, those pages need to be optimized, therefore, to solve traffic problems also need accurate statistical analysis can, I recommend the use of traffic analysis statistics software is Google Analytics (Google Analytics)

Optimization Experience:

First learn to use explain statements to analyze SELECT statements, optimize indexes, table structure, second, reasonable motion memcache and other caches

Reduce the load on MySQL

Finally, try compiling PHP with Facebook's hiphop-php to improve program efficiency.

The solution of large traffic and high concurrency of PHP website

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.