Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Profiler for a live system on top of Apache

Tags:

php

profiling

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.

like image 539
The Unknown Avatar asked Jun 09 '09 19:06

The Unknown


3 Answers

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

like image 150
Paul Dixon Avatar answered Nov 20 '22 04:11

Paul Dixon


Try XDebug ( http://www.xdebug.org/ ) you can trigger it with a get-parameter during your debugging-session. This will create cachegrind-files which you can check within KCacheGrind or WinCacheGrind (this first is much better)...

like image 27
pagid Avatar answered Nov 20 '22 06:11

pagid


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

like image 3
kannan Avatar answered Nov 20 '22 05:11

kannan