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

My site is slow, what can I do? – Profiling PHP...

My site is slow, what can I do? – Profiling PHP applications

It’s nothing new that speed is important for the success of any web application. Only a few hundred milliseconds may lie between a user leaving your site or staying. Unfortunately performance problems are oftentimes hard to fix and even harder to pinpoint.
In this talk I will show you how we at ResearchGate measure web application performance, which means not only timing how long the PHP backend took to deliver a page, but also tracking the speed the users actually perceives in the browser. After that you will see how you can track down and analyze any problems you found through measuring with the help of tools like Xdebug, XHProf, Blackfire.io, Tideways.io and the Symfony Debug Toolbar. And if you still need to get faster after optimizing and fixing all these issues, I’ll introduce you to some tricks, techniques and patterns to even further decrease load times.

Bastian Hofmann

October 08, 2015
Tweet

More Decks by Bastian Hofmann

Other Decks in Programming

Transcript

  1. browser JS: boomerang logstash trackingServer access log requests tracking image

    with timing information as query parameters graphite statsd
  2. input {
 file {
 type => "pagespeed-access"
 path => [

    "/var/log/nginx/ access_log/monitoring-access.log" ]
 }
 }
  3. filter{
 grok {
 type => "pagespeed-access"
 pattern => "^.*\s\"[A-Z]+\s[^\?\s]+ \?page=%{DATA:page}\&connectTime=%

    {NUMBER:connectTime}...)?\sHTTP\/\d\.\d\".* $"
 }
 grok {
 type => "pagespeed-access"
 match => ["page", "^(profile| home|...)\.logged(In|Out)$"]
 exclude_tags => ["_grokparsefailure"]
 }
 }
  4. output { statsd { type => "pagespeed-access" exclude_tags => ["_grokparsefailure"]

    host => "localhost" port => 8126 namespace => "pagespeed" sender => "" timing => [ "%{page}.connect", "% {connectTime}", ... ] } }
  5. input {
 file {
 type => "haproxy-http-log"
 path => [

    "/var/log/ haproxy-http.log*" ]
 }
 }
  6. filter {
 grok {
 type => "haproxy-http-log"
 pattern => "%{HAPROXYHTTP}"

    
 }
 mutate {
 type => "haproxy-http-log"
 gsub => [
 "server_name", "\.", "_",
 "client_ip", "\.", "_"
 ]
 }
 }
  7. output {
 statsd {
 type => "haproxy-http-log"
 exclude_tags => ["_grokparsefailure"]


    host => "localhost"
 port => 8125
 namespace => "lb"
 sender => ""
 increment => [
 "haproxy.%{backend_name}.%{server_name}.% {client_ip}.hits",
 "haproxy.%{backend_name}.%{server_name}.% {client_ip}.responses.%{http_status_code}"
 ]
 timing => [
 "haproxy.%{backend_name}.%{server_name}.% {client_ip}.time_request", "%{time_request}",
 "haproxy.%{backend_name}.%{server_name}.% {client_ip}.time_backend_connect", "%{time_backend_connect}",
 "haproxy.%{backend_name}.%{server_name}.% {client_ip}.time_backend_response", "%{time_backend_response}",
 "haproxy.%{backend_name}.%{server_name}.% {client_ip}.time_queue", "%{time_queue}",
 "haproxy.%{backend_name}.%{server_name}.% {client_ip}.time_duration", "%{time_duration}"
 ]
 }

  8. browser JS: boomerang logstash trackingServer access log requests tracking image

    with timing information as query parameters graphite statsd logstash load balancer access log logstash service access log
  9. ESI

  10. Profile Publications Publication Publication Publication AboutMe LeftColumn Image Menu <div

    id="placeholder"></div> <script>loadWidget('/aboutMe', function(w) { w.render({ replace : '#placeholder' }); })</script> Institution
  11. $future = new HTTPFuture( 'http://www.example.com/' ); // do something else

    list($status, $body, $headers) = $future->resolve();