Performance and optimization

1,828 views
1,725 views

Published on

Slides from a talk given at TrueNorthPHP 2013

Published in: Technology
1 Comment
6 Likes
Statistics
Notes
No Downloads
Views
Total views
1,828
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
9
Comments
1
Likes
6
Embeds 0
No embeds

No notes for slide

Performance and optimization

  1. 1. PROFILING & OPTIMIZATION Tools, guidelines, and techniques Saturday, 9 November, 13
  2. 2. PERFORMANCE Saturday, 9 November, 13
  3. 3. GETTING BUY-IN Saturday, 9 November, 13
  4. 4. HIGHER CONVERSION RATES Saturday, 9 November, 13
  5. 5. SLOW MOBILE CONNECTIONS Saturday, 9 November, 13
  6. 6. RULES; MORE LIKE GUIDELINES Saturday, 9 November, 13
  7. 7. Guideline MEASURE EVERYTHING Saturday, 9 November, 13
  8. 8. Guideline HUNT THE BIG FISH Saturday, 9 November, 13
  9. 9. Guideline START CHEAP & ITERATE Saturday, 9 November, 13
  10. 10. Cost Order Minify assets Compress images Reduce number of HTTP requests Optimize database queries Add caching Code optimization Saturday, 9 November, 13
  11. 11. JUNK UP FRONT Saturday, 9 November, 13
  12. 12. Junk Up Front Saturday, 9 November, 13
  13. 13. Measuring Chrome developer tools Saturday, 9 November, 13
  14. 14. Junk up front Number of requests Number of hosts Image count & image size Script count & script size Saturday, 9 November, 13
  15. 15. Fixing Smushit (pngcrush, jpegtran, imagemagick) Uglify.js, CSSMin Make, phing, rake, grunt, shell scripts Saturday, 9 November, 13
  16. 16. Image sprites Easy way to reduce requests, and overall page size. Data-URIs. Icon WebFonts. Saturday, 9 November, 13
  17. 17. Guideline AVOID WORK TO GO FASTER Saturday, 9 November, 13
  18. 18. WEBSERVER TRICKS Saturday, 9 November, 13
  19. 19. Measuring Chrome developer tools Saturday, 9 November, 13
  20. 20. Webserver tricks GZIP all the things. Far Future cache headers. Consider a CDN. Saturday, 9 November, 13
  21. 21. SQL MOLASSES Saturday, 9 November, 13
  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. Saturday, 9 November, 13
  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. Saturday, 9 November, 13
  24. 24. Explain Queries Visual explain makes it easier. Saturday, 9 November, 13
  25. 25. Indexes Index commonly used columns. Column order in matters in indexes. Saturday, 9 November, 13
  26. 26. CACHING Saturday, 9 November, 13
  27. 27. Caching Can be expensive to rollout, if you need new infrastructure Cache expiration is really really hard. Saturday, 9 November, 13
  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. Saturday, 9 November, 13
  29. 29. Where to cache Hopefully in RAM Failing that in shared memory Disk :( Saturday, 9 November, 13
  30. 30. Optimize cache use Watch cache miss rate. Tune cache expiration so you miss less often. Saturday, 9 November, 13
  31. 31. Guideline OPTIMIZE CODE LAST, MOST OF THE TIME Saturday, 9 November, 13
  32. 32. JAVASCRIPT Saturday, 9 November, 13
  33. 33. PHP Saturday, 9 November, 13
  34. 34. Javascript tools Chrome dev tools are the gold standard. CPU profiles are invaluable. Heap comparisons can be used to find memory leaks. Saturday, 9 November, 13
  35. 35. CPU Profiler Chrome dev tools Saturday, 9 November, 13
  36. 36. CPU Profiler Chrome dev tools Saturday, 9 November, 13
  37. 37. CPU Profiler Chrome dev tools Saturday, 9 November, 13
  38. 38. CPU Profiler Chrome dev tools Saturday, 9 November, 13
  39. 39. PHP TOOLS Saturday, 9 November, 13
  40. 40. XHProf PECL extension produced by Facebook. Captures runtime metrics at a function level. Possible to use in a sub-sample of production unlike xdebug. Saturday, 9 November, 13
  41. 41. Xhgui Nicer UI to XHProf data Saturday, 9 November, 13
  42. 42. Xhgui Nicer UI to XHProf data Saturday, 9 November, 13
  43. 43. XDebug Not suitable for servers with traffic, Very detailed results. Saturday, 9 November, 13
  44. 44. Webgrind XDebug UI Saturday, 9 November, 13
  45. 45. Other PHP tweaks Opcode caching is a must. Don’t use file based sessions. Saturday, 9 November, 13
  46. 46. RECAP Saturday, 9 November, 13
  47. 47. MEASURE EVERYTHING Saturday, 9 November, 13
  48. 48. BE THRIFTY Saturday, 9 November, 13
  49. 49. START IN THE FRONT Saturday, 9 November, 13
  50. 50. AVOID WORK Saturday, 9 November, 13
  51. 51. OPTIMIZE CODE Saturday, 9 November, 13
  52. 52. THANKS Saturday, 9 November, 13
  53. 53. Thanks mark_story on Twitter. markstory on Github. Rate this talk: https://joind.in/9994 Saturday, 9 November, 13

×