PHP Profiler for a live system on top of Apache

2020-07-11 09:26发布

I have a PHP website on a Apache server, and I would like to know if there are tools and other ways I can profile this to find bottlenecks on the code. What I need to know is what functions are taking long to process, etc.

Something like gprof, except for PHP on live apache server.

What are other ways to find bottlenecks in a PHP system.

标签: php profiling
9条回答
萌系小妹纸
2楼-- · 2020-07-11 09:38

If you are running on OpenSolaris, consider dtrace. The biggest advantage probably is that you can also probe into other layers like Apache, Mysql. dtrace has low overhead and you can selectively enable only the probes that you want to monitor.

查看更多
别忘想泡老子
3楼-- · 2020-07-11 09:40

You can use xdebug - once installed you can trigger profiling of requests in a variety of ways, and you wind up with a valgrind format profile for each request. Load this in WinCacheGrind, KCacheGrind or similar and drill down to find where all the time is spent!

alt text

查看更多
成全新的幸福
4楼-- · 2020-07-11 09:40

Let me also mention Pinba
In my opinion, it is more suitable for the multiple servers setup rather than for just one server, but in case your project grow..

查看更多
We Are One
5楼-- · 2020-07-11 09:49

dtrace has low overhead

dtrace in fact has almost zero overhead unless you enable thousands of probes think it is also available on the BSD's

查看更多
Melony?
6楼-- · 2020-07-11 09:50

XHProf was designed for this use case.

XHProf (open sourced by Facebook in 2009) powers Facebook's XHProfLive -- a real-time performance monitoring system that provides function level insights from production tiers.

A snippet from XHProf doc:

XHProf is a light-weight instrumentation based profiler. During the data collection phase, it keeps track of call counts and inclusive metrics for arcs in the dynamic callgraph of a program. It computes exclusive metrics in the reporting/post processing phase. XHProf handles recursive functions by detecting cycles in the callgraph at data collection time itself and avoiding the cycles by giving unique depth qualified names for the recursive invocations.

XHProf's light-weight nature and aggregation capabilities make it well suited for collecting "function-level" performance statistics from production environments.

regards, Kannan Muthukkaruppan

查看更多
Root(大扎)
7楼-- · 2020-07-11 09:52

You can use phpdebug for this job. It's a php extension.

查看更多
登录 后发表回答