How to profile mod_perl applications

One of the serious limitation in Perl is an absence of a possibility to make code debugging and profiling in case mod_perl applications. For example PHP has very good development environment – Zend Studioâ„¢ developed by Zend which includes realtime profiler and debugger of web applications:
Zend Profiler
It’s useful to find some bottle necks in the web applications.
Perl dasn’t have such tool. Hovewer, there at least three modules in CPAN which can help to debug and make profiling of Perl code under Apache and mod_perl: Apache::DB, Apache::DProf and Apache::SmallProf
Apache::DB is provides a way to debug mod_perl applications. It works exactly the same as Perl debugger. It needs to configure a little bit. First of all add
PerlFixupHandler +Apache::DB
into the <directory> or <location> where a mod_perl handler installed, add following to the startup.pl:

use APR::Pool ();
use Apache::DB ();
Apache::DB->init();

and restart Apache server with the -X command-line option to tell Apache to launch only one back-end process and to not fork into the background. But this approach will work only on server side and it will stop working of production server if you want to debug it. Also, you should have root privileges to do that. In real case it isn’t acceptable.
With code profiling it’s getting on better. You have to just configure modules and have access to view results. The difference beween Apache::DProf and Apache::SmallProf is in the level of profiling. Apache::DProf shows information on a subroutine level. But Apache::SmallProf gives details in a line-by-line. So, to find a problem in the code it’s better to use first Apache::DProf and then Apache::SmallProf to provide more details.
Good point to start is an article below by Frank Wiles.

Published by

Michael Stepanov

Site owner and admin :)

Leave a Reply

Your email address will not be published. Required fields are marked *