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

Performance analysis for php devs

Performance analysis for php devs

When writing web applications performance is something that is often in the back of our minds and often times we rely on folklore tales of things that are said to improve performance, but rarely ever do we challenge or confirm them. In this talk I want to showcase some tools that help us change this bad habit of generalizing performance advice and instead focus on how we can improve our application where it hurts.

This talk introduces both established and new tools for profiling PHP applications and running performance tests on our infrastructure. Along the way we will discuss how to continuously keep an eye on key performance metrics by making them part of our development process and what general advice might be useful in our day to day work as developers and if there are some tips we can safely ignore.


Denis Brumann

January 29, 2019


  1. User Group Vienna Performance Analysis ...but is it web scale?

  2. Denis Brumann denis.brumann@sensiolabs.de @dbrumann Deutschland

  3. WHAT WILL WE COVER? Tools Guidelines for performance testing General

  4. WHY? Developer experience Save money Make money Save the environment


  6. dev stage prod Profiler adsr/phpspy XHProf

  7. ADSR/PHPSPY Low overhead
 sampling profiler for PHP 7 https://github.com/adsr/phpspy

  8. None
  9. None
  10. XHPROF originally built for PHP 5 can be used in

    production https://tideways.com/profiler/xhprof-for-php7
  11. None
  12. None
  13. XDEBUG do not use in production! debugging garbage collection stats

    profiler https://xdebug.org/
  14. None
  15. CACHEGRIND visualisation tool for profiles
 generated with XDebug kcachegrind, qcachegrind,

  16. None
  17. PHP-MEMINFO https://github.com/BitOne/php-meminfo

  18. None
  19. None
  20. Profiler Example App:

  21. None
  22. None
  23. {{ render(controller('App\\Controller\\GroupController::listAction')) }} {{ render(controller('App\\Controller\\EventController::listAction')) }}

  24. None
  25. None
  26. None
  27. None
  28. None
  29. None
  30. None
  31. None
  32. https://symfony.com/doc/current/testing/profiling.html

  33. None
  34. It can be used to simulate a heavy load on

    a server, group of servers, network or object to test its strength or to analyze overall performance under different load types. https://jmeter.apache.org/
  35. None
  36. None
  37. None
  38. None
  39. None
  40. None
  41. None
  42. None
  43. None
  44. None
  45. None
  46. None
  47. None
  48. WEB SERVER access & error logs DB size, throughput, slow

    queries CACHE size, hits vs. misses, connections SYSTEM cpu & mem usage, disk i/o
  49. None
  50. None
  51. None
  52. None
  53. None
  54. None
  55. None
  56. WHAT TO LOOK FOR? reading from & writing to disk

    network calls & latency database queries CPU & memory usage

  58. WRITING EFFICIENT CODE single vs. double quotes \count() vs. count()

    avoid regexes tabs instead of spaces
  59. WRITING EFFICIENT CODE single vs. double quotes \count() vs. count()

    avoid regexes tabs instead of spaces
  60. MICRO-OPTIMIZATIONS RARELY ARE THE ISSUE focus on data often there

    are huge gains around: API-Requests, DB-Queries,
  61. MICRO-OPTIMIZATIONS RARELY ARE THE ISSUE automate micro-optimizations, if you want,

    but focus on
 measured bottlenecks (see tools)
  62. None

  64. None
  65. None
  66. https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching

  67. Caching does not
 improve your app's performance Caching allows for

    easier scaling
  68. None
  69. WHAT TO DO? Measure Improve Measure again Compare Incremental changes

    Don't guess/assume Don't trust benchmarks Re-evaluate old data