Successfully reported this slideshow.

More Related Content

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

Site Performance - From Pinto to Ferrari

  1. 1. Hello
  2. 2. This Slide Intentionally Left Blank
  3. 3. This One Too
  4. 4. Site Performance from Pinto to Ferrari Joseph Scott joseph@josephscott.org http://josephscott.org/
  5. 5. Find Me http://josephscott.org/ joseph@josephscott.org @josephscott
  6. 6. The Pinto
  7. 7. http://www.flickr.com/photos/autohistorian/4439476737/
  8. 8. http://www.flickr.com/photos/autohistorian/4439476737/
  9. 9. http://www.flickr.com/photos/thomashawk/2466245846/
  10. 10. http://www.flickr.com/photos/autohistorian/4439476737/
  11. 11. http://www.flickr.com/photos/autohistorian/4439476737/
  12. 12. http://www.flickr.com/photos/autohistorian/4439476737/
  13. 13. http://www.flickr.com/photos/autohistorian/4439476737/
  14. 14. http://www.flickr.com/photos/autohistorian/4439476737/
  15. 15. The Ferrari
  16. 16. Steve Souders http://stevesouders.com/
  17. 17. 2007
  18. 18. 2009
  19. 19. Why Did I Choose This Topic?
  20. 20. I Want My Site To Be Faster
  21. 21. I Want My Site To Be Faster Less Like A Pinto
  22. 22. I Want My Site To Be Faster More Like A Ferrari
  23. 23. How Fast Is It Now?
  24. 24. How Fast Is It Now? Tools For Measuring Site Performance
  25. 25. Tools webpagetest.org pagespeed.googlelabs.com Firefox & Firebug Chrome/Safari & Dev Tools HttpWatch
  26. 26. Where To Start?
  27. 27. Where To Start? http://www.webpagetest.org/
  28. 28. webpagetest.org Test Location Browser Connection Speed Video
  29. 29. Browsers IE 8 still most commonly used browser (26.5% / 28.5%) http://gs.statcounter.com/#browser_version-na-monthly-201106-201108-bar
  30. 30. Connection Speed FIOS 20Mbps
  31. 31. http://www.webpagetest.org/result/110827_KZ_1EBDB/1/details/
  32. 32. Which Part?
  33. 33. The Initial Request Get the source for the page
  34. 34. The Initial Request Get the source 0.113 seconds for the page
  35. 35. The Initial Request DNS Lookup: 5 ms Initial Connection: 47 ms Time to First Byte: 57 ms Content Download: 4 ms Bytes In (downloaded): 9.6 KB Bytes Out (uploaded): 0.4 KB
  36. 36. Requests Per Page November 2010: 69 August 2011: 76 http://www.stevesouders.com/blog/2011/08/17/http-archive-nine-months/
  37. 37. Thinking Clearly About Performance http://carymillsap.blogspot.com/2010/02/thinking- clearly-about-performance.html
  38. 38. Average Lies List A List B 0.924 0.796 0.928 0.798 0.954 0.802 0.957 0.823 0.961 0.919 0.965 0.977 0.972 1.076 0.979 1.216 0.987 1.273 1.373 1.320 pg3, Exhibit 1
  39. 39. Aim For Consistent Performance
  40. 40. Know Your Limits Calculate the theoretical best performance for your setup
  41. 41. Know Your Limits Calculate the theoretical best performance for your setup What ever you actually end up with will be slower than that
  42. 42. Moving Up The Stack
  43. 43. The Stack Network
  44. 44. The Stack Server Hardware Network
  45. 45. The Stack Operating System Server Hardware Network
  46. 46. The Stack HTTP Operating System Server Hardware Network
  47. 47. The Stack HTTP PHP Operating System Server Hardware Network
  48. 48. The Stack HTTP PHP MySQL Operating System Server Hardware Network
  49. 49. The Stack WordPress HTTP PHP MySQL Operating System Server Hardware Network
  50. 50. The Stack WordPress HTTP PHP MySQL Operating System Server Hardware Network
  51. 51. HTTP - The Web Server Apache remove any modules you aren’t using turn off host name lookups turn off FollowSymLinks turn off .htaccess (if you can) turn on compression (mod_deflate) tweak MaxClients
  52. 52. HTTP - The Web Server Apache - mod_pagespeed http://code.google.com/speed/page-speed/docs/module.html http://code.google.com/p/modpagespeed/
  53. 53. HTTP - The Web Server Consider Alternatives Nginx
  54. 54. HTTP - The Web Server HTTP Compression Keep-alive support Correctly Configured Caching
  55. 55. ETag Survey HTTP/1.1 200 OK ETag: "cd7ac991ff11"
  56. 56. ETag Survey If-None-Match: "cd7ac991ff11" HTTP/1.1 304 NOT MODIFIED
  57. 57. ETag Survey ETags used by 136 of the top 1,000 U.S. sites http://josephscott.org/archives/2011/09/etag-survey/
  58. 58. ETag Survey Of the 136 sites using ETags: 54 Worked Correctly (39.7%) 11 Sort of Worked (8%) 71 Broken/Useless (52.2%)
  59. 59. Understanding PHP
  60. 60. Understanding PHP Lifespan .php Read Parse Compile Execute Output
  61. 61. Understanding PHP Lifespan .php Read Parse Compile Execute Output Apache / mod_php
  62. 62. Understanding PHP .php Lifespan Read Parse Compile Execute Output FastCGI Nginx
  63. 63. Reading Open Read Close
  64. 64. Reading Open Read Close Avoid co$tly services like NFS
  65. 65. Parse hello.php <?php echo "Hello, World!n" Parse error: syntax error, unexpected $end, expecting ',' or ';' in /tmp/hello.php on line 3
  66. 66. Tokens <?php echo $tokens = token_get_all( ' "Hello, World!";' );
  67. 67. foreach ( $tokens as $token ) {     if ( is_array( $token ) ) {         echo token_name( $token[0] ) . " ( {$token[2]} ) - {$token[1]}n";     } else {         echo "{$token}n";     } }
  68. 68. T_OPEN_TAG ( 1 ) - <?php T_ECHO ( 1 ) - echo T_WHITESPACE ( 1 ) - T_CONSTANT_ENCAPSED_STRING ( 1 ) - "Hello, World!" ;
  69. 69. Compile
  70. 70. Branch analysis from position: 0 Return found filename: /tmp/hello.php function name: (null) number of ops: 3 compiled vars: none line # op fetch ext return operands ------------------------------------------------------------------------------- 2 0 ECHO 'Hello%2C+World%21%0A' 3 1 RETURN 1 2* ZEND_HANDLE_EXCEPTION
  71. 71. Execute Deceptively Simple Term •Includes all sorts of activity •Database / remote requests
  72. 72. Output •PHP can buffer output •Don’t forget about compression
  73. 73. Making PHP Faster
  74. 74. Making PHP Faster .php Read Parse Compile Execute Output
  75. 75. Making PHP Faster .php Read APC Parse Compile Execute Output
  76. 76. Making PHP Faster .php Read APC Parse Compile Execute Output opcode cache
  77. 77. PHP - opcode caching APC requests per second - increased 4x time per request - decreased 4x
  78. 78. Use An Opcode Cache (APC)
  79. 79. Use An Opcode Cache (APC)!
  80. 80. APC == Free Money
  81. 81. APC == Free Money
  82. 82. PHP use an opcode cache (APC) use newer versions don’t use on static files (unless you really need to) consider output buffering be careful with preg_* functions profile your running code (Xdebug, VLD) don’t re-invent native PHP functions, they are likely faster than yours
  83. 83. The Stack WordPress HTTP PHP MySQL Operating System Server Hardware Network
  84. 84. MySQL use InnoDB table type (unless you have a really good reason not to) use the slow query log use EXPLAIN on queries, learn what the output means double triple check your indexes learn about quirks
  85. 85. The Stack WordPress HTTP PHP MySQL Operating System Server Hardware Network
  86. 86. Memcached “Free & open source, high-performance, distributed memory object caching system” in memory only, won’t survive a reboot key/value data store http://memcached.org/
  87. 87. WordPress + Memcached Memcached Object Cache Persistent data store for WordPress objects Reduces the number of database queries http://wordpress.org/extend/plugins/memcached/
  88. 88. I’m Batcache
  89. 89. WordPress + Memcached Batcache Persistent data store for rendered pages http://wordpress.org/extend/plugins/batcache/
  90. 90. WordPress Caching - Alternatives WP Super Cache http://wordpress.org/extend/plugins/wp-super-cache/ W3 Total Cache http://wordpress.org/extend/plugins/w3-total-cache/
  91. 91. But Wait, There’s More!
  92. 92. MySQL Replication Master / Slave one way, asynchronous send writes to the master send reads to the slave supports multiple slaves, and chaining
  93. 93. WordPress + HyperDB Drop in replacement for default DB class distributed reads and writes partition data http://wordpress.org/extend/plugins/hyperdb/
  94. 94. What Could This Look Like?
  95. 95. What Could This Look Like? Net web & database
  96. 96. What Could This Look Like? Net db web
  97. 97. What Could This Look Like? db Net web memcached
  98. 98. What Could This Look Like? db db Net web memcached memcached
  99. 99. What Could This Look Like? web db db load web balancer web memcached memcached
  100. 100. Variations slave just for backups multiple data centers task specific web servers
  101. 101. When Things Go Wrong
  102. 102. Hire an Amazing SysAdmin
  103. 103. Questions?
  104. 104. Find Me http://josephscott.org/ joseph@josephscott.org @josephscott

Editor's Notes

  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • ×