Performance analysis of peripheral resources in PHP development (2)

Source: Internet
Author: User
Performance analysis of peripheral resources in PHP development (2) For the moment, we will not discuss whether PHP is the best programming language. This article will analyze the backend peripheral resources and front-end peripheral resources of the PHP program, respectively, their impact on the overall PHP Web application experience, this is often much larger than the language itself.

In the previous article, we analyzed the impact of I/O operations and middleware services in backend peripheral resources on the overall PHP Web application experience. Today, we analyze the impact of the database on the performance of the entire application.

Database

First, let's look at the two figures. one is the Web transaction throughput graph from the OneAPM background, that is, the number of Web transactions triggered per minute and the number of database transactions triggered ,.

As shown above, Web transactions fluctuate between 150 and 200 times per minute, and the corresponding data operations also reach the corresponding volume.

The above shows the total number of database requests and the proportion of the total number of requests. we can see that the use of the database is very heavy. As we all know, this average analysis is incorrect. When calculating the traffic peak, we may only calculate 30% of the time as the peak time. at the same time, we only focus on the performance of 20% of the main requests. Therefore, from a specific page, the proportion of database usage on a common Web application page.

From the preceding XHProf report, we can see that this page has a total of 89 database requests, consuming 44.5% of the total page time. This is still a normal page and a normal request, with so many requests, it is easy to think that if the remote database slows down and the network gets stuck, each request consumes an average of 3-5 ms, the overall page speed is approaching from 208 ms latency to 500 ms.

Summary

Although PHP language optimization is significant, it is always controllable, and performance bottlenecks often appear on uncontrollable external resources. For example, the annual 12306 crash is not caused by the performance of the language itself, but by the lack of external resources and architecture problems. Of course, we cannot deny that the huge difference between language and language saves resources. for example, Didi's background services are switching from PHP to Go, that is, PHP consumes several times of Go resources.

As an analysis of PHP peripheral resources, this article has designed some experimental scenarios and seen the impact of external resources, including I/O, middleware, and database resources, on program performance. How can we eliminate and optimize bottlenecks in these scenarios? This is actually a big topic. I will not discuss it in detail in this article, but I will also introduce the general principles of external resource optimization. This is an image I admire. it is very vivid and comprehensive, and summarizes the database optimization rules. these rules are also applicable to the optimization of other external resources ,.

The figure shows the following points:

1. the biggest optimization for external resource usage is to reduce resource usage. This is also the optimization of business logic and cache. The performance improvement brought by the two is usually an order of magnitude.
2. All optimization is a comprehensive project, and it will not start from a single point of failure once and for all. To optimize the disk, network, CPU, and memory.
3. adding resources, that is, adding hardware configuration, is the final optimization solution. If possible, software optimization is used as much as possible to improve performance. compared with hardware optimization, this solution is cheap and efficient.

This is the back-end peripheral resources that affect the performance of PHP programs. in the next article, we will analyze the impact of front-end or front-end combination on page latency.

OneAPM for PHP can go deep into all PHP applications to complete application performance management. it can go deep into all PHP applications to complete application performance management and monitoring, including visibility of code-level performance problems, fast identification and tracing of performance bottlenecks, Real User Experience Monitoring, server monitoring, and end-to-end application performance management.

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.