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.
Develop with xDebug and webgrind (a GUI) locally. Use XHProf and XHGui (a GUI) on production. Optionally also use php-meminfo.
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.
- 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.