Allows websites to fly and PHP programs to accelerate exploration

Source: Internet
Author: User
(1) Introduction This article attempts to explore various aspects of PHP program acceleration, including the necessity and specific measures taken from different perspectives. Hope to help readers understand the PHP program acceleration and apply it to reality. (2) is acceleration required? It sounds silly. In this era, few people doubt that time is the most valuable asset, especially in the commercial market. The faster the program is executed, the more time the user saves, so that your program can use less time and server resources. (1) Introduction
This article attempts to explore various aspects of PHP program acceleration, including the necessity and specific measures taken from different perspectives. Hope to help readers understand the PHP program acceleration and apply it to reality.
  
   (2) is acceleration required?
It sounds silly. In this era, few people doubt that time is the most valuable asset, especially in the commercial market. The faster the program runs, the more time the user saves. in this way, your program can use less time and server resources to serve the user, thus generating more benefits.
I think for most people (including myself), many WEB projects have been completed in a very short time and are usually not carefully considered and strictly tested. Start a new WEB project. Many people are building fast and messy applications and lack the necessary time to adjust and improve code. Optimization and acceleration are the measures we must take.
However, not all programs require acceleration.
It is a waste of time to optimize the completed code. The best way is to pay attention to the efficiency when writing the code. after the project is completed, only the part that needs to be optimized is optimized. Generally, a program only has a few bottlenecks that affect the speed. you can find and solve them to run the program well. In addition, when the execution efficiency is low, we should first look at the overall situation to find out the main factors that affect the efficiency, rather than sticking to the details-for example, the data volume is too large and the server bandwidth is insufficient, or the hardware configuration is too low. in this case, optimization code is useless.
In addition, when there are no obvious signs of slow execution in the program, do not be too picky. it is a waste of time to improve some very detailed code. With this time, you can complete another project or complete an extension function for the original project. Of course, you can joke that I am not responsible enough to do my job well. I can also say that you are a perfectionist :-)
In summary, before you decide to speed up your PHP program, ask yourself if it is necessary.
  
   (3) how to accelerate?
Before answering the question "how to accelerate", you need to answer the following two questions:
Where is your program slow?
Which of the following aspects can PHP accelerate?
Obviously, I cannot give you the answer to the first small question, but I suggest you use the "test script execution speed" method to solve it. How to solve this problem can be considered only by identifying the bottleneck that limits the speed.
The second small question is my approximate answer: code optimization, compression output, content cache output, function cache output, and acceleration/cache tool software. If you know more, please let me know :-)
Next, let's take a detailed look at the relevant technologies in these aspects. Of course, there are countless details in every aspect to discuss. the following content will inevitably be one-sided. please add it.
  
<1> test
◆ Server load test
  
It is also common that the server load is too large and the program efficiency is affected. we need to test this. Here I take the most common apache (the most popular WEB server platform on Unix) server as an example.
Apache (the most popular WEB server platform on the Unix platform) server comes with a tool named AB (apache (the most popular WEB server platform on the Unix platform) license) under the bin directory. With this lightweight tool, we can test the server load to see how the server performs under heavy loads. Apache (the most popular WEB server platform on Unix) idea can simulate continuous online requests for a specific URL. It can also simulate online requests with the same number of points at the same time, therefore, the use of apache (the most popular WEB server platform on the Unix platform) license can help us simulate possible online Conditions During website development, use the simulated data as the basis for adjusting server settings or programs.
Output in the command line:
  
./AB-n number_of_total_requests-c number_of_simultaneous_requests http: // your_web_server/your_php_app.php
  
For example:
  
./AB-n 1000-c 50 http://www.domain.com/myapp.php
  
At the same time, AB will send 50 concurrent requests to http://www.domain.com/myapp.php, with a total of requests.
The test results may be as follows:
  
Server Software: apache (the most popular WEB Server platform on Unix)/2.0.16
Server Hostname: localhost
Server Port: 80
Document Path:/myapp. php
Document Length: 1311 bytes
Concurrency Level: 50
Time taken for tests: 8.794 seconds
Complete requests: 1000
Failed requests: 0
Total transferred: 1754000 bytes

9 7 3123456 4 8:

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.