0
Hello
This Slide Intentionally      Left Blank
This One Too
Site Performancefrom Pinto to Ferrari                   Joseph Scott       joseph@josephscott.org         http://josephsco...
Find Mehttp://josephscott.org/joseph@josephscott.org@josephscott
The Pinto
http://www.flickr.com/photos/autohistorian/4439476737/
http://www.flickr.com/photos/autohistorian/4439476737/
http://www.flickr.com/photos/thomashawk/2466245846/
http://www.flickr.com/photos/autohistorian/4439476737/
http://www.flickr.com/photos/autohistorian/4439476737/
http://www.flickr.com/photos/autohistorian/4439476737/
http://www.flickr.com/photos/autohistorian/4439476737/
http://www.flickr.com/photos/autohistorian/4439476737/
The Ferrari
Steve Soudershttp://stevesouders.com/
2007
2009
Why Did I Choose This Topic?
I Want My Site To Be Faster
I Want My Site To Be Faster        Less Like A Pinto
I Want My Site To Be Faster     More Like A Ferrari
How Fast Is It Now?
How Fast Is It Now?Tools For Measuring   Site Performance
Toolswebpagetest.orgpagespeed.googlelabs.comFirefox & FirebugChrome/Safari & Dev ToolsHttpWatch
Where To Start?
Where To Start?http://www.webpagetest.org/
webpagetest.orgTest LocationBrowserConnection SpeedVideo
Browsers      IE 8 still most commonly   used browser (26.5% / 28.5%)http://gs.statcounter.com/#browser_version-na-monthly...
Connection Speed FIOS 20Mbps
http://www.webpagetest.org/result/110827_KZ_1EBDB/1/details/
Which Part?
The Initial RequestGet the source for the page
The Initial RequestGet the source                      0.113 seconds for the page
The Initial RequestDNS Lookup: 5 msInitial Connection: 47 msTime to First Byte: 57 msContent Download: 4 msBytes In (downl...
Requests Per PageNovember 2010: 69August 2011: 76http://www.stevesouders.com/blog/2011/08/17/http-archive-nine-months/
Thinking Clearly About              Performancehttp://carymillsap.blogspot.com/2010/02/thinking-          clearly-about-pe...
Average LiesList A                    List B0.924                     0.7960.928                     0.7980.954           ...
Aim For Consistent Performance
Know Your LimitsCalculate the theoretical best performance               for your setup
Know Your LimitsCalculate the theoretical best performance               for your setup  What ever you actually end up wit...
Moving Up The Stack
The Stack Network
The StackServer Hardware   Network
The StackOperating SystemServer Hardware    Network
The StackHTTP       Operating System       Server Hardware           Network
The StackHTTP        PHP       Operating System       Server Hardware           Network
The StackHTTP        PHP           MySQL       Operating System       Server Hardware           Network
The Stack          WordPressHTTP        PHP           MySQL       Operating System       Server Hardware           Network
The Stack          WordPressHTTP        PHP           MySQL       Operating System       Server Hardware           Network
HTTP - The Web ServerApache  remove any modules you aren’t using  turn off host name lookups  turn off FollowSymLinks  tur...
HTTP - The Web Server    Apache - mod_pagespeedhttp://code.google.com/speed/page-speed/docs/module.html  http://code.googl...
HTTP - The Web ServerConsider Alternatives               Nginx
HTTP - The Web Server    HTTP Compression     Keep-alive supportCorrectly Configured Caching
ETag SurveyHTTP/1.1 200 OKETag: "cd7ac991ff11"
ETag SurveyIf-None-Match: "cd7ac991ff11"HTTP/1.1 304 NOT MODIFIED
ETag SurveyETags used by 136 of the top      1,000 U.S. sites http://josephscott.org/archives/2011/09/etag-survey/
ETag SurveyOf the 136 sites using ETags:  54 Worked Correctly (39.7%)  11 Sort of Worked (8%)  71 Broken/Useless (52.2%)
Understanding PHP
Understanding PHP           Lifespan.phpRead    Parse   Compile   Execute   Output
Understanding PHP            Lifespan.phpRead    Parse    Compile   Execute   Output        Apache      /      mod_php
Understanding PHP.php           LifespanRead    Parse   Compile   Execute   Output                FastCGI                 ...
ReadingOpen    Read     Close
ReadingOpen            Read        Close   Avoid   co$tly services like NFS
Parsehello.php            <?php            echo "Hello, World!n"Parse error: syntax error, unexpected $end,expecting , or ...
Tokens              <?php echo$tokens = token_get_all(   "Hello, World!"; );
foreach ( $tokens as $token ) {    if ( is_array( $token ) ) {        echo token_name( $token[0] ) . " ( {$token[2]} ) -  ...
T_OPEN_TAG ( 1 ) - <?phpT_ECHO ( 1 ) - echoT_WHITESPACE ( 1 ) -T_CONSTANT_ENCAPSED_STRING ( 1 ) - "Hello,  World!";
Compile
Branch analysis from position: 0Return foundfilename:     /tmp/hello.phpfunction name: (null)number of ops: 3compiled vars:...
ExecuteDeceptively Simple Term•Includes all sorts of activity•Database / remote requests
Output•PHP can buffer output•Don’t forget about compression
Making PHP Faster
Making PHP Faster.phpRead    Parse   Compile   Execute   Output
Making PHP Faster.phpRead    APC        Parse   Compile   Execute   Output
Making PHP Faster.phpRead    APC        Parse   Compile   Execute   Output         opcode cache
PHP - opcode caching              APCrequests per second - increased 4x  time per request - decreased 4x
Use An Opcode Cache              (APC)
Use An Opcode Cache             (APC)!
APC == Free Money
APC == Free Money
PHPuse an opcode cache (APC)use newer versionsdon’t use on static files (unless you really need to)consider output bufferin...
The Stack          WordPressHTTP        PHP           MySQL       Operating System       Server Hardware           Network
MySQLuse InnoDB table type (unless you have areally good reason not to)use the slow query loguse EXPLAIN on queries, learn...
The Stack          WordPressHTTP        PHP           MySQL       Operating System       Server Hardware           Network
Memcached“Free & open source, high-performance,distributed memory object cachingsystem”  in memory only, won’t survive a r...
WordPress + Memcached     Memcached Object Cache       Persistent data store for WordPress objects       Reduces the numbe...
I’m Batcache
WordPress + Memcached   Batcache      Persistent data store for rendered pageshttp://wordpress.org/extend/plugins/batcache/
WordPress Caching - Alternatives  WP Super Cache    http://wordpress.org/extend/plugins/wp-super-cache/  W3 Total Cache   ...
But Wait, There’s More!
MySQL ReplicationMaster / Slave  one way, asynchronous  send writes to the master  send reads to the slave  supports multi...
WordPress + HyperDB   Drop in replacement for default DB class      distributed reads and writes      partition datahttp:/...
What Could This Look Like?
What Could This Look Like?Net         web & database
What Could This Look Like?Net                db         web
What Could This Look Like?                   dbNet         web                memcached
What Could This Look Like?                  db          dbNet         web               memcached   memcached
What Could This Look Like?           web      db          db  load     webbalancer           web   memcached   memcached
Variationsslave just for backupsmultiple data centerstask specific web servers
When Things Go Wrong
Hire an Amazing SysAdmin
Questions?
Find Mehttp://josephscott.org/joseph@josephscott.org@josephscott
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to Ferrari
Upcoming SlideShare
Loading in...5
×

Site Performance - From Pinto to Ferrari

7,014

Published on

Published in: Technology
1 Comment
7 Likes
Statistics
Notes
No Downloads
Views
Total Views
7,014
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
42
Comments
1
Likes
7
Embeds 0
No embeds

No notes for slide
  • \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
  • Transcript of "Site Performance - From Pinto to Ferrari"

    1. 1. Hello
    2. 2. This Slide Intentionally Left Blank
    3. 3. This One Too
    4. 4. Site Performancefrom Pinto to Ferrari Joseph Scott joseph@josephscott.org http://josephscott.org/
    5. 5. Find Mehttp://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 Soudershttp://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. Toolswebpagetest.orgpagespeed.googlelabs.comFirefox & FirebugChrome/Safari & Dev ToolsHttpWatch
    26. 26. Where To Start?
    27. 27. Where To Start?http://www.webpagetest.org/
    28. 28. webpagetest.orgTest LocationBrowserConnection SpeedVideo
    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 RequestGet the source for the page
    34. 34. The Initial RequestGet the source 0.113 seconds for the page
    35. 35. The Initial RequestDNS Lookup: 5 msInitial Connection: 47 msTime to First Byte: 57 msContent Download: 4 msBytes In (downloaded): 9.6 KBBytes Out (uploaded): 0.4 KB
    36. 36. Requests Per PageNovember 2010: 69August 2011: 76http://www.stevesouders.com/blog/2011/08/17/http-archive-nine-months/
    37. 37. Thinking Clearly About Performancehttp://carymillsap.blogspot.com/2010/02/thinking- clearly-about-performance.html
    38. 38. Average LiesList A List B0.924 0.7960.928 0.7980.954 0.8020.957 0.8230.961 0.9190.965 0.9770.972 1.0760.979 1.2160.987 1.2731.373 1.320 pg3, Exhibit 1
    39. 39. Aim For Consistent Performance
    40. 40. Know Your LimitsCalculate the theoretical best performance for your setup
    41. 41. Know Your LimitsCalculate 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 StackServer Hardware Network
    45. 45. The StackOperating SystemServer Hardware Network
    46. 46. The StackHTTP Operating System Server Hardware Network
    47. 47. The StackHTTP PHP Operating System Server Hardware Network
    48. 48. The StackHTTP PHP MySQL Operating System Server Hardware Network
    49. 49. The Stack WordPressHTTP PHP MySQL Operating System Server Hardware Network
    50. 50. The Stack WordPressHTTP PHP MySQL Operating System Server Hardware Network
    51. 51. HTTP - The Web ServerApache 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_pagespeedhttp://code.google.com/speed/page-speed/docs/module.html http://code.google.com/p/modpagespeed/
    53. 53. HTTP - The Web ServerConsider Alternatives Nginx
    54. 54. HTTP - The Web Server HTTP Compression Keep-alive supportCorrectly Configured Caching
    55. 55. ETag SurveyHTTP/1.1 200 OKETag: "cd7ac991ff11"
    56. 56. ETag SurveyIf-None-Match: "cd7ac991ff11"HTTP/1.1 304 NOT MODIFIED
    57. 57. ETag SurveyETags used by 136 of the top 1,000 U.S. sites http://josephscott.org/archives/2011/09/etag-survey/
    58. 58. ETag SurveyOf 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.phpRead Parse Compile Execute Output
    61. 61. Understanding PHP Lifespan.phpRead Parse Compile Execute Output Apache / mod_php
    62. 62. Understanding PHP.php LifespanRead Parse Compile Execute Output FastCGI Nginx
    63. 63. ReadingOpen Read Close
    64. 64. ReadingOpen Read Close Avoid co$tly services like NFS
    65. 65. Parsehello.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 ) - <?phpT_ECHO ( 1 ) - echoT_WHITESPACE ( 1 ) -T_CONSTANT_ENCAPSED_STRING ( 1 ) - "Hello, World!";
    69. 69. Compile
    70. 70. Branch analysis from position: 0Return foundfilename: /tmp/hello.phpfunction name: (null)number of ops: 3compiled vars: noneline # op fetch ext return operands------------------------------------------------------------------------------- 2 0 ECHO Hello%2C+World%21%0A 3 1 RETURN 1 2* ZEND_HANDLE_EXCEPTION
    71. 71. ExecuteDeceptively 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.phpRead Parse Compile Execute Output
    75. 75. Making PHP Faster.phpRead APC Parse Compile Execute Output
    76. 76. Making PHP Faster.phpRead APC Parse Compile Execute Output opcode cache
    77. 77. PHP - opcode caching APCrequests 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. PHPuse an opcode cache (APC)use newer versionsdon’t use on static files (unless you really need to)consider output bufferingbe careful with preg_* functionsprofile your running code (Xdebug, VLD)don’t re-invent native PHP functions, they are likelyfaster than yours
    83. 83. The Stack WordPressHTTP PHP MySQL Operating System Server Hardware Network
    84. 84. MySQLuse InnoDB table type (unless you have areally good reason not to)use the slow query loguse EXPLAIN on queries, learnwhat the output meansdouble triple check your indexeslearn about quirks
    85. 85. The Stack WordPressHTTP PHP MySQL Operating System Server Hardware Network
    86. 86. Memcached“Free & open source, high-performance,distributed memory object cachingsystem” 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 querieshttp://wordpress.org/extend/plugins/memcached/
    88. 88. I’m Batcache
    89. 89. WordPress + Memcached Batcache Persistent data store for rendered pageshttp://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 ReplicationMaster / 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 datahttp://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? dbNet web memcached
    98. 98. What Could This Look Like? db dbNet web memcached memcached
    99. 99. What Could This Look Like? web db db load webbalancer web memcached memcached
    100. 100. Variationsslave just for backupsmultiple data centerstask specific web servers
    101. 101. When Things Go Wrong
    102. 102. Hire an Amazing SysAdmin
    103. 103. Questions?
    104. 104. Find Mehttp://josephscott.org/joseph@josephscott.org@josephscott
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×