Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Profiling PHP With XHProf

Profiling PHP With XHProf

Measuring and improving the performance of your PHP application is critical to giving your customers a great experience. To get a realistic view of where the time spent in PHP is actually going, you need to profile your code. XHProf is an open source, low overhead, robust profiling tool for PHP. This talk will explain how to install it, leverage its most important features, and solve the kinds of problems that XHProf can help identify. XHProf has a browser based UI, which makes it extremely easy to use and to share code profiles with coworkers. I will be demoing various traces, talking about PHP micro-optimizations, and showing you how to quickly drill down and find the slowest parts of your site. By using XHProf to identify the big wins, you can spend less time optimizing and more time building new features. You will come away from this talk with a working knowledge of XHProf, and the ability to get it up and running in your environment in minutes.

Jonathan Klein

February 07, 2014
Tweet

More Decks by Jonathan Klein

Other Decks in Technology

Transcript

  1. Who Am I? • Performance Engineer at Etsy • Boston

    Web Perf Meetup Organizer Friday, February 7, 14
  2. Agenda • Why do you care? • Installing XHProf/XHGui •

    Analyzing the data Friday, February 7, 14
  3. Agenda • Why do you care? • Installing XHProf/XHGui •

    Analyzing the data • Takeaways Friday, February 7, 14
  4. Real World Examples • Shopzilla: -5 seconds = 7-12% increase

    in revenue http://www.phpied.com/the-performance-business-pitch/ Friday, February 7, 14
  5. Real World Examples • Shopzilla: -5 seconds = 7-12% increase

    in revenue • Firefox: -2.2 seconds = 15.4% more downloads http://www.phpied.com/the-performance-business-pitch/ Friday, February 7, 14
  6. Real World Examples • Shopzilla: -5 seconds = 7-12% increase

    in revenue • Firefox: -2.2 seconds = 15.4% more downloads • Google: +400ms = 0.76% fewer searches http://www.phpied.com/the-performance-business-pitch/ Friday, February 7, 14
  7. Real World Examples • Shopzilla: -5 seconds = 7-12% increase

    in revenue • Firefox: -2.2 seconds = 15.4% more downloads • Google: +400ms = 0.76% fewer searches • Amazon: +100ms = -1% revenue http://www.phpied.com/the-performance-business-pitch/ Friday, February 7, 14
  8. A fast page load is 1 second This means you

    have 200ms to get that HTML to the client Friday, February 7, 14
  9. But network time could be ~100ms This means you have

    200ms 100ms to build the page Friday, February 7, 14
  10. < 100ms feels instant < 1 sec feels responsive <

    10 sec to keep user’s attention http://www.nngroup.com/articles/response-times-3-important-limits/ Friday, February 7, 14
  11. < 100ms feels instant < 1 sec feels responsive <

    10 sec to keep user’s attention Full Page Load – 1 Second http://www.nngroup.com/articles/response-times-3-important-limits/ Friday, February 7, 14
  12. < 100ms feels instant < 1 sec feels responsive <

    10 sec to keep user’s attention Full Page Load – 1 Second Base HTML – 200ms http://www.nngroup.com/articles/response-times-3-important-limits/ Friday, February 7, 14
  13. < 100ms feels instant < 1 sec feels responsive <

    10 sec to keep user’s attention Full Page Load – 1 Second Base HTML – 200ms Server Generation Time – 100ms http://www.nngroup.com/articles/response-times-3-important-limits/ Friday, February 7, 14
  14. Steps • Install MongoDB • Install XHProf • Install XHGui

    • Generate some data Friday, February 7, 14
  15. Steps • Install MongoDB • Install XHProf • Install XHGui

    • Generate some data Friday, February 7, 14
  16. Steps • Install MongoDB • Install XHProf • Install XHGui

    • Generate some data Friday, February 7, 14
  17. Steps • Install MongoDB • Install XHProf • Install XHGui

    • Generate some data Friday, February 7, 14
  18. Steps • Install MongoDB • Install XHProf • Install XHGui

    • Generate some data Friday, February 7, 14
  19. Steps • Install MongoDB • Install XHProf • Install XHGui

    • Generate some data Friday, February 7, 14
  20. Steps • Install MongoDB • Install XHProf • Install XHGui

    • Generate some data Friday, February 7, 14
  21. Steps • Install MongoDB • Install XHProf • Install XHGui

    • Generate some data Friday, February 7, 14
  22. Steps • Install MongoDB • Install XHProf • Install XHGui

    • Generate some data Friday, February 7, 14
  23. XHGui + Vagrant • Install VirtualBox • Install Vagrant •

    http://goo.gl/GS837H Friday, February 7, 14
  24. XHGui + Vagrant • Install VirtualBox • Install Vagrant •

    http://goo.gl/GS837H • vagrant up Friday, February 7, 14
  25. XHGui + Vagrant • Install VirtualBox • Install Vagrant •

    http://goo.gl/GS837H • vagrant up • http://localhost:8080 Friday, February 7, 14
  26. Workflow • Run XHProf • Find expensive functions • Instrument

    with StatsD (optional) Friday, February 7, 14
  27. Workflow • Run XHProf • Find expensive functions • Instrument

    with StatsD (optional) • See performance in prod (optional) Friday, February 7, 14
  28. Workflow • Run XHProf • Find expensive functions • Instrument

    with StatsD (optional) • See performance in prod (optional) • Optimize Friday, February 7, 14
  29. Advantages of XHProf • Nicer UI • Share-ability • Ease

    of setup/configuration Friday, February 7, 14
  30. Advantages of XHProf • Nicer UI • Share-ability • Ease

    of setup/configuration • Hackability Friday, February 7, 14