Skip to content

Instantly share code, notes, and snippets.

@bashilbers
Last active December 15, 2017 06:23
Show Gist options
  • Save bashilbers/9d650facb7ac07d95aad to your computer and use it in GitHub Desktop.
Save bashilbers/9d650facb7ac07d95aad to your computer and use it in GitHub Desktop.
Web application performance tuning

Clientside profiling (ABSOLUTE MUST)

You can either:

  • Do it yourself:
    • Hook into the Navigation and Resource timing API
    • Emit requests to a static nginx webserver
    • The nginx server should return a 200 empty response
    • Parse the access_log with logstash
    • Monitor the performance with graphite
  • Or, use a SaaS ($$$), e.g.

Debugging PHP:

Develop with xDebug and webgrind (a GUI) locally. Use XHProf and XHGui (a GUI) on production. Optionally also use php-meminfo.

Extra:

Working in symfony? Use the symfony debug toolbar on production, just make sure the visitors can't see it and dump data every once in a while.

Profiling PHP:

Some other best practices:

  • Gzip input and output
  • Hire/buy a CDN for assets
  • Look at database indexes and slow queries
  • Run EXPLAIN EXTENDED on slow queries.
  • Minify JavaScript and CSS files.
  • Send correct cache headers
  • Use an Opcache (included in php 5.5.0+)
  • Upgrade to the latest stable PHP version.
  • Cache all your data when possible.
  • Use the Spdy/HTTP2 protocol.
  • Minimalize unnecessary redirects (scan access_log).
  • Compress images or inject base64 encoded ones in your HTML.
  • Compress HTML (remove whitespace).
  • Check Yslow pagespeed.
  • Enable Dns-prefetch on tags (see http://davidwalsh.name/html5-prefetch).
  • Offload long-running tasks to separate workers (use exec() or a dedicated job queue) e.g. mails, caching tasks, database inserts etc.)
  • Use a reverse proxy cache (varnish) for serving static content.
  • use Edge Side Includes for partially cache-able templates.
  • Code your javascript asynchronously.
  • Flush content early in the same HTTP request.
  • Move logic to the shutdown handler.

links

Perfplanet.com

proflingphpapplications.mp4 from fosdem 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment