Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to locate the slow access to php programs

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

The company's business is developed in PHP, so nine times out of ten, the environment used is LNMP. In the daily operation and maintenance work, more than 90% of the faults are performance problems.

You may think, our business is running well, why do we have performance problems for no reason?

There are too many possible reasons, such as code changes, abnormal access, network fluctuations, server hardware failures, and so on.

There are so many reasons for performance problems, how to locate them?

To introduce you to a performance tracking method, this method has been successful in my operation and maintenance career, and has helped me a lot.

-slow log tracking-

We can easily track the problem point through slow log. Let's first look at the configuration method.

1) Edit configuration file

Assume that the php installation path is / usr/local/php, the configuration file path / usr/local/php/etc/php-fpm.conf)

# vim / usr/local/php/etc/php-fpm.conf # change or add two lines slowlog = / data/logs/php-slow.logrequest_slowlog_timeout = 2

Description: slowlog defines the log path and name, request_slowlog_timeout defines the timeout, in seconds, that is, if the execution time of a php script exceeds this time, the log will be recorded.

2) restart the php-fpm service

Specific restart commands are determined according to your own environment. After the configuration file is modified, it will not take effect if you do not restart or reload the service.

3) Test

Create a new test.php file in the test site and write the following:

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report