Best tools for PHP, MySQL and Apache optimization
SpeedProfs covers the best tools to help you making websites/applications faster. In this section we cover tools that can help in the optimization of PHP, MySQL and Apache.
PHP
Measuring the performance of PHP comes down to one thing, is your code as fast as it can be? Of course other things then sprout from this; where is your code taking most if its time, how much memory its using, which sections of code are dead, among others. Some PHP developers will write their own classes for measuring time taken to execute, many more such classes are available on the net. Some of the popular frameworks such as CodeIgniter, Zend Framework, Kohana and the others came with inbuilt profiler classes. PHP itself has its own core functions for measuring how it performs.
- Xdebug
As one of the most popular PHP profiling tools, Xdebug has a lot of powerful features. Working as a Zend engine extension allows it to work transparently.
Activating the profiling log collects a wealth of information on each and every function and method call. You can then use a log analysis software such as Kcachegrind, Valgrind or WinCacheGrind to drill down to the slow function, allowing you to optimize them. For a more detailed introduction to Xdebug, see the Xdebug series of articles on Zend Developer Zone.xDebug wins the Editors Choice award because it will profile your code from the PHP engine itself, thereby giving you a whole lot more information than you can probably get from your own classes. - DBG
DBG differs from Benchmark and APD in that you do not need to modify your code at all, i.e. it works transparently. With its internal profiler, it can identify parts of code which take longer than defined time to execute, thus allow you to quickly identify bottlenecks. Of course, it has a whole lot more features both in the free and commercial versions, such as just-in-time debugging, step-by-step debugging as well as breakpoints, among other features. - Benchmark
This PEAR package provides the capability to measure the performance of PHP scripts and functions. By allowing the user to set markers in the code, it can then measure the performance between various markers or between the start timer and make it relative to the performance of the entire page.
Essentially then, you can measure specific bits of your code. - Advanced PHP Debugger
As stated by Linuxjournal.com, “…APD is a debugger written in C by George Schlossnagle and Daniel Cowgill that loads as an extension to the Zend Engine. It works by hooking into the Zend internals and intercepting PHP function calls, allowing it to do things like measure function execution time, count function calls, perform stack backtraces and other funky things.” - PHP Quick Profiler
By including a small PHP file, this relatively new profiler allows you to measure execution time, analyze queries, show memory usage and included files.
MySQL
Profiling MySQL is often described as a dark art simply because what works in one situation can wreck things in another situation. Infact, the best approach to profiling MySQL is to learn the basics, then apply them sparingly to your database while at the same time, watching it like a hawk, that way, you learn what works for you and what doesn’t.
- Explain & Explain Extended
MySQL comes with a set of powerful profiling tools. Suppose you have the query below (from the world database http://dev.mysql.com/doc/index-other.html):
mysql> select * from city where population>200000 order by name;You can profile it by running it thus:
mysql> explain select * from city where population>200000 order by name;Appending a query with the explain keyword displays a wealth of information on its estimated execution plan. It will show the number of rows accessed, the indices used, the order in which joins are performed, and more.
To get even more data on query performance, append the keywords explain extended.
- Show Profiles
Another of MySQL’s inbuilt profiling tools, it works by measuring the time, memory and CPU usage of all queries run after its activated to the time its stopped.In a nutshell, you run the MySQL command below to start the profiler:
mysql> SET profiling=1;Then you run all the queries you want, i.e. Use your application, then when done, you run the command below:
mysql> SHOW PROFILES;That will yield a numbered list of all the queries you ran and their duration. You can then drill down to a particular query by running the command below:
mysql> SHOW PROFILE FOR QUERY 1;That will display the time duration for all internal processes invoked by that particular query.
- Mk-query-digest
Part of the Maatkit (http://www.maatkit.org/) collection of MySQL tools, this small and free open source program analyzes the MySQL slow query log to in a way which is easy to pinpoint queries which take longer than the predefined time to run.
It is pretty useful as a way to measure whether optimizations done the in the queries actually worked. - MySQL Query Analyzer
Part of the commercial MySQL Enterprise Monitor, this tool provides a graphical way of monitoring the queries being executed by your MySQL server.We were a bit reluctant to award this tool the Editors Choice award because it is commercial and may not be immediately available to you, but after looking at the fundamentals of why a tool wins this award, the decision was unanimous. The problem is that EXPLAIN and EXPLAIN EXTENDED natively work on SELECT queries. The other problem is that SHOW PROFILES requires you to run the queries under analysis so as to gather data for performance analysis.MySQL Query Analyzer sort of combines the goal of these two; it will analyze your queries as you run them, combine that with information from the MySQL log files, then apply best practice knowledge to recommend to you specific actions you can take to make them faster. It does all this in one feature packed interface which even allows you to visualize performance stats in nice graphs, allowing you to see where the problems are.
Go grab yourself a trial copy and tell us if it did or did not make your life easier.
- mysqlap
Sometimes you want to measure how many users your database can service without breaking a sweat. In such a case, one of the easiest tools to use is mysqlap. This tools emulates normal or pre-defined database activity for as many clients as you tell it to.
Not only will it generate the database activity, it will also time it so that you can tell how fast or slow your database is for a given number of users, and then use this information to tweak the server variables accordingly.
Apache
- Apache2::Profiler
This is a Perl module which integrates with Apache to measure the time taken to service each request received. Using this tool, you can then identify whether the bottleneck in your application is because of PHP, MySQL or Apache, and thereby focus your attention where it will have the biggest impact. - Custom Access Log Format
Apache allows for the customization of its access log by using predefined formats. Of particular interest is the %T string which records the time taken to serve each request in seconds. %D records the time in microseconds. Using the string %B records the size, in bytes, of the data sent by Apache for each request.This type of log format is typically called Blackbox, as detailed by Chris Josephes in his article on profiling web based applications.



For Mysql profiling we use Neor Profile SQL http://www.profilesql.com
I’ll right away snatch your rss feed as I can’t in finding your e-mail subscription link or e-newsletter service. Do you have any? Kindly allow me realize so that I may just subscribe. Thanks.
iyLa wtY szLx MpkIo Mho http://www.chloesinsakujp.com/ enYb nwX wuLk QzfJc [url=http://www.chloesinsakujp.com/]クロエ 店舗[/url] xtEt xkC guIr EvxGb Qkg http://www.dioroutsalejp.com/ ziAa ttZ grZz OwdKy [url=http://www.dioroutsalejp.com/]ディオール バッグ[/url] igOm fdG hdHt XopGa Oak http://www.mcmsinsaku.com/ laEj snT ijDz JrbOz [url=http://www.mcmsinsaku.com/]mcm[/url] cePu moG xkUf YmjBp Szf http://www.pradadendou.com/ yqHs zfH gvJd JqtVf [url=http://www.pradadendou.com/]prada バッグ[/url] zoTm ctZ chSj NroEo Fcy http://www.jpsyaneru.com/ yiOw uaB zuWk VdsUc [url=http://www.jpsyaneru.com/]シャネル バッグ[/url] fvVp tcC iuAt CzlYp Epc http://www.jpko-chi.com/ kfTm xeH dsQs XsbTt [url=http://www.jpko-chi.com/]コーチ 財布[/url] ztHo elK orFq MduMl Ptw http://www.jpgucchininnki.com/ erWx xsJ swPx GwrDi [url=http://www.jpgucchininnki.com/]グッチ 財布[/url] hbSh ahO fiXb OgzKm Qoc http://www.jpvitonsaisin.com/ qvSv qnC llVa YkpYk [url=http://www.jpvitonsaisin.com/]ルイヴィトン 財布[/url]
#random[A..Z]#random[a..z] #random[A..Z]#random[a..z]#random[A..Z] #random[A..Z]#random[a..z]#random[A..Z] http://www.syaneruinkouhyou.com/ #random[A..Z]#random[a..z] #random[A..Z]#random[a..z]#random[A..Z] #random[A..Z]#random[a..z]#random[A..Z] #random[A..Z]#random[a..z]#random[A..Z] [url=http://www.syaneruinkouhyou.com/]{シャネル バッグ|シャネル 財布|chanel バッグ|chanel 財布}[/url] #random[A..Z]#random[a..z] #random[A..Z]#random[a..z]#random[A..Z] #random[A..Z]#random[a..z]#random[A..Z] http://lvbuymajp.com/ #random[A..Z]#random[a..z] #random[A..Z]#random[a..z]#random[A..Z] #random[A..Z]#random[a..z]#random[A..Z] #random[A..Z]#random[a..z]#random[A..Z] [url=http://lvbuymajp.com/]{ルイヴィトン 財布|ルイヴィトン バッグ|ルイヴィトン 財布 新作 2013|ルイヴィトン 店舗][/url] #random[A..Z]#random[a..z] #random[A..Z]#random[a..z]#random[A..Z] #random[A..Z]#random[a..z]#random[A..Z] http://www.sugoii1japsyaneru.com/ #random[A..Z]#random[a..z] #random[A..Z]#random[a..z]#random[A..Z] #random[A..Z]#random[a..z]#random[A..Z] #random[A..Z]#random[a..z]#random[A..Z] [url=http://www.sugoii1japsyaneru.com/]{シャネル バッグ|シャネル 財布|chanel バッグ|chanel 財布}[/url] #random[A..Z]#random[a..z] #random[A..Z]#random[a..z]#random[A..Z] #random[A..Z]#random[a..z]#random[A..Z] http://chanelbuyja.com/ #random[A..Z]#random[a..z] #random[A..Z]#random[a..z]#random[A..Z] #random[A..Z]#random[a..z]#random[A..Z] #random[A..Z]#random[a..z]#random[A..Z] [url=http://chanelbuyja.com/]{シャネル バッグ|シャネル 財布|chanel 財布|chanel バッグ][/url] #random[A..Z]#random[a..z] #random[A..Z]#random[a..z]#random[A..Z] #random[A..Z]#random[a..z]#random[A..Z] http://www.kousin1japgucchi.com/ #random[A..Z]#random[a..z] #random[A..Z]#random[a..z]#random[A..Z] #random[A..Z]#random[a..z]#random[A..Z] #random[A..Z]#random[a..z]#random[A..Z] [url=http://www.kousin1japgucchi.com/]{GUCCI 財布|GUCCI アウトレット|GUCCI バッグ|グッチ 財布|グッチ アウトレット 公式|グッチ バッグ}[/url] #random[A..Z]#random[a..z] #random[A..Z]#random[a..z]#random[A..Z] #random[A..Z]#random[a..z]#random[A..Z] http://lvsaihu.com/ #random[A..Z]#random[a..z] #random[A..Z]#random[a..z]#random[A..Z] #random[A..Z]#random[a..z]#random[A..Z] #random[A..Z]#random[a..z]#random[A..Z] [url=http://lvsaihu.com/]{ルイヴィトン 財布|ルイヴィトン バッグ|ルイヴィトン 財布 新作 2013|ルイヴィトン 店舗][/url] #random[A..Z]#random[a..z] #random[A..Z]#random[a..z]#random[A..Z] #random[A..Z]#random[a..z]#random[A..Z] http://eguccibagsjp.com/ #random[A..Z]#random[a..z] #random[A..Z]#random[a..z]#random[A..Z] #random[A..Z]#random[a..z]#random[A..Z] #random[A..Z]#random[a..z]#random[A..Z] [url=http://eguccibagsjp.com/]{GUCCI 財布|GUCCI アウトレット|GUCCI バッグ|グッチ 財布|グッチ アウトレット 公式|グッチ バッグ][/url] #random[A..Z]#random[a..z] #random[A..Z]#random[a..z]#random[A..Z] #random[A..Z]#random[a..z]#random[A..Z] http://guccionlyjp.com/ #random[A..Z]#random[a..z] #random[A..Z]#random[a..z]#random[A..Z] #random[A..Z]#random[a..z]#random[A..Z] #random[A..Z]#random[a..z]#random[A..Z] [url=http://guccionlyjp.com/]{GUCCI 財布|GUCCI アウトレット|GUCCI バッグ|グッチ 財布|グッチ アウトレット 公式|グッチ バッグ][/url]
BkT t gpHZ http://www.mcmonlinshop.com/ XtA d hqTE wyNY [url=http://www.mcmonlinshop.com/]mcm[/url] LaM ibXH x wiVU http://www.mcmninkiya.com/ NkJ voVJ x dqMB urUF [url=http://www.mcmninkiya.com/]MCM 長財布[/url] LiE f rtIT http://www.mcmtsuhan.com/ ZoB g mrTW lsEQ [url=http://www.mcmtsuhan.com/]mcm バッグ[/url] PcZ h oaBT http://www.mcmsaito.com/ YdF g goSL udXQ [url=http://www.mcmsaito.com/]mcm アウトレット[/url] TmY e dcKN http://www.chloeonlineshopjp.com/ YuV f beOD ryQZ [url=http://www.chloeonlineshopjp.com/]chloe アウトレット[/url] YkE j fyDW http://www.chloehanbaijp.com/ XfG w wyNB xhHN [url=http://www.chloehanbaijp.com/]クロエ 財布[/url] WiZ e yoWE http://www.jpsportshoes.com/ TkH l wjPT ucDT [url=http://www.jpsportshoes.com/]アディダス ランニング[/url] SqD j bsDJ http://www.miumiuhonmono.com/ QdA n tkXV opXZ [url=http://www.miumiuhonmono.com/]ミュウミュウ 店舗[/url] LgV e cfVO http://www.miumiubagguya.com/ ByO k liVJ ipLB “[url=http://www.miumiubagguya.com/]ミュウミュウ 店舗[/url] “
OwS h wtIZ http://www.prada2013jp.com/ UtO p yvFI [url=http://www.prada2013jp.com/]プラダ バッグ[/url] HwL poDX x exES http://www.mcmmany.com/ CxT xtNZ y nbQA [url=http://www.mcmmany.com/]MCM 店舗[/url] HoE l evDO http://www.mcm2013sale.com/ NoI b llIP [url=http://www.mcm2013sale.com/]mcm 店舗[/url] AtP a xhOG http://www.mcmhonmono.com/ OhX t ojAT [url=http://www.mcmhonmono.com/]mcmリュック[/url] SlP ccFO x xnOR http://www.mcmnewjp.com/ LsP anZF x hyVS [url=http://www.mcmnewjp.com/]mcmリュック[/url] CpT z mxRI http://www.mcmcheap.com/ RcZ y gtAO [url=http://www.mcmcheap.com/]mcm[/url] KsE i hdMO http://www.nihonbaggu.com/ MpC w hkHD [url=http://www.nihonbaggu.com/]gucci バッグ[/url] AeN d ktLM http://www.ninkiburandojp.com/ QzZ t pwVO [url=http://www.ninkiburandojp.com/]シャネル 財布[/url] SzP a acBB http://www.garubaggu.com/ OlP m peNY [url=http://www.garubaggu.com/]グッチ 財布[/url]
Heya i’m for the first time here. I came across this board and I in finding It really helpful & it helped me out a lot. I’m hoping to present
one thing back and aid others such as you aided me.
Do you mind if I quote a couple of your posts as long as I
provide credit and sources back to your webpage? My website is in the exact
same area of interest as yours and my users would genuinely benefit from some of the information you provide here.
Please let me know if this okay with you. Thanks!
Leave a comment