Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Performance and optimization CakeFest 2014

1,477 views

Published on

A talk I gave at Cakefest 2014

Published in: Software
  • Be the first to comment

Performance and optimization CakeFest 2014

  1. 1. PROFILING & OPTIMIZATION Tools, guidelines, and techniques
  2. 2. PERFORMANCE
  3. 3. WHY BOTHER?
  4. 4. HIGHER CONVERSION RATES
  5. 5. SLOW MOBILE CONNECTIONS
  6. 6. CONSERVE CAPACITY
  7. 7. RULES; MORE LIKE GUIDELINES
  8. 8. Guideline MEASURE EVERYTHING
  9. 9. Guideline HUNT THE BIG FISH
  10. 10. Guideline START CHEAP & ITERATE
  11. 11. Cost Order Minify assets Compress images Reduce the number of HTTP requests Optimize database queries Add caching Code optimization
  12. 12. JUNK UP FRONT
  13. 13. Junk Up Front
  14. 14. Measuring Chrome developer tools
  15. 15. Junk up front Number of requests Number of hosts Image count & image size Script count & script size
  16. 16. Fixing Smushit (pngcrush, jpegtran, imagemagick) Uglify.js, CSSMin Make, phing, rake, grunt, shell scripts Image sprites
  17. 17. Guideline AVOID WORK TO GO FASTER
  18. 18. WEBSERVER TRICKS
  19. 19. Measuring Chrome developer tools
  20. 20. Webserver tricks GZIP all the things. Far Future cache headers. Consider a CDN.
  21. 21. SQL MOLASSES
  22. 22. Database slowness Many backend performance issues are caused by too many, or slow queries. Mysql has a pretty terrible query planner. Sub-queries and derived table joins will eventually catch fire. Slow query logs, mtop, or monitoring like new relic are your best friend.
  23. 23. Database slowness Slow query logs - Percona makes great tools for MySQL. Disable query caching. Run EXPLAIN on slow queries. Add indexes/tweak queries, and repeat.
  24. 24. Explain Queries Visual explain makes it easier.
  25. 25. Indexes Index commonly used columns. Column order in matters in indexes.
  26. 26. CACHING
  27. 27. Caching Can be expensive to rollout, if you need new infrastructure Cache expiration is really really hard.
  28. 28. What to Cache Results that don’t change often Use monitoring/analytics to find the busiest pages. Start using caching there. Expand once you’ve learned more.
  29. 29. Where to cache Hopefully in Memcache/Redis Failing that in Apc/Wincache Files - Sometimes not faster.
  30. 30. Optimize cache use Watch cache miss rate. Tune cache expiration so you miss less often.
  31. 31. Guideline OPTIMIZE CODE LAST, MOST OF THE TIME
  32. 32. JAVASCRIPT
  33. 33. PHP
  34. 34. Javascript tools Chrome dev tools are the gold standard. CPU profiles are invaluable. Heap comparisons can be used to find memory leaks.
  35. 35. Cpu Profiler Chrome dev tools
  36. 36. Cpu Profiler Chrome dev tools
  37. 37. Cpu Profiler Chrome dev tools
  38. 38. Cpu Profiler Chrome dev tools
  39. 39. PHP TOOLS
  40. 40. Debug Kit Deeper insights into CakePHP
  41. 41. XHProf PECL extension produced by Facebook. Captures runtime metrics at a function level. Possible to use in a sub-sample of production unlike xdebug.
  42. 42. Xhgui Nicer UI to XHProf data
  43. 43. Xhgui Nicer UI to XHProf data
  44. 44. XDebug Not suitable for servers with traffic, Very detailed results.
  45. 45. Webgrind XDebug UI
  46. 46. Other PHP tweaks Opcode caching is a must. Don’t use file based sessions.
  47. 47. RECAP
  48. 48. MEASURE EVERYTHING
  49. 49. BE THRIFTY
  50. 50. START IN THE FRONT
  51. 51. AVOID WORK
  52. 52. OPTIMIZE CODE
  53. 53. THANKS

×