How PHP solves the problem of large traffic and high concurrency _php Digest

Source: Internet
Author: User
Tags dedicated server
First, verify that the server hardware is sufficient to support the current traffic.

Ordinary P4 servers generally support up to 100,000 independent IP per day, if the number of visits is larger than this,
Then you must first configure a higher-performance dedicated server to solve the problem

, or how optimization can not completely solve performance problems.

Second, optimize database access.

The foreground realizes completely static of course best, can not access the database completely, but for frequently updated website,
Static often does not satisfy certain functions.

Caching technology is another solution, which is to store dynamic data in a cached file, which is called directly by the Dynamic Web page
These files without having to access the database, both WordPress and Z-blog Use this caching technique heavily. I
I have also written a z-blog counter plug-in, also based on this principle.

If you do not avoid access to the database, you can try to optimize query SQL for the database. Avoid using
Select * from such statements, each query only returns the results of their own needs, to avoid a short period of large
Measure SQL query.

Third, the prohibition of external hotlinking.

External Web site image or file hotlinking often bring a lot of load pressure, so should be strictly restricted external to
In its own picture or file hotlinking, fortunately at present can simply through the refer to control the hotlinking, Apache from
Can be configured to prohibit hotlinking, IIS also has some Third-party ISAPI can achieve the same function. When
However, the forgery of refer can also be achieved through the code hotlinking, but the current deliberate falsification of refer hotlinking is not much,
You can not think about it, or use a non technical means to solve, such as in the image to add watermark.

Four, control the download of large files.

Large file downloads can take up a lot of traffic, and for non-SCSI hard drives, a large number of file downloads consume
CPU, so that the Web site response ability to decline. Therefore, try not to provide more than 2M of large file downloads, if necessary
, it is recommended that you put large files on a different server.

V, the main flow of the use of different mainframe streaming

Put the files on a different host, providing different mirrors for the user to download. For example, if you feel that RSS files occupy
Flow is large, then use FeedBurner or Feedsky and other services to put the RSS output on other hosts, which
The kind of traffic pressure that other people visit is concentrated on FeedBurner host, RSS does not occupy too many resources.

Use the flow analysis statistics software.

Install a traffic analysis and statistics software on the Web site to instantly know which places are consuming a lot of traffic and which pages
The surface needs to be optimized again, therefore, the solution flow problem also needs to carry on the accurate statistical analysis to be possible. I recommend making
The flow analysis statistic software used is Google Analytics (Google Analytics). I use the process to feel its
The effect is very good, I will give a detailed introduction to Google Analytics Some of the use of common sense and skills.

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.