Php perfomance problem fast analysys

Posted: 19

In this article I show how to find perfomance problem in couple steps:

When you want to find perfomance problem in your php application, you have to choose tool for that.

There are actually couple of them: xdebug profiler, xhprof (created by Facebook). For analysys xdebug results you have to install some analyze tool like KCachegrind, xdebugtoolkit, WinCacheGrind, or Webgrind.

For xhprof is enoght couple things described in this article.

Prepare env

1. I use php-7 compatible xhprof fork from


RUN cd /tmp && git clone && \
cd php-profiler-extension && \
phpize && \
./configure && \
make && make install && \
echo "" >> /usr/local/etc/php/conf.d/ext-xhprof.ini

install tideways toolkit:

export GOPATH="/home/$USER/code/golang"
go get
sudo ln -s /home/$USER/code/golang/bin/toolkit /usr/local/bin/tk


Prepare app


define('XHPROF_PROFILE', true);
// ...
// application work here
// ...
if (XHPROF_PROFILE) { $data = tideways_xhprof_disable(); file_put_contents(
"/src/app/Profiling/" . uniqid('app_') . ".app.xhprof",
json_encode($data) ); }

Analyze results:

tk generate-xhprof-graphviz
dot -Tpng > app.png

As we can see the main bottleneck in my case is processing templates. 

The next things is code investiogation why this bottleneck happened. For example,  I have a lot of records on the page that include separate template part which cause perrfomance issues. 


If you find the post helpful you can share it

Ваше мнение:

   other with PHP
drcreazy © 2008-2012 all rights reserved