Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Scale Out Don't Scale Up

25e2ecf9b520e06d71e47ab083924300?s=47 xyu
May 16, 2015

Scale Out Don't Scale Up

Installing WordPress and getting it to serve up a site is easy. Getting that same site to stay up when millions are hitting it is not so much. In this talk We’ll go over both the tools and techniques to keep your site up as well as the theory behind operating at scale.

25e2ecf9b520e06d71e47ab083924300?s=128

xyu

May 16, 2015
Tweet

More Decks by xyu

Other Decks in Technology

Transcript

  1. Scale Out Don’t Scale Up WordCamp Maine (May 2014)

  2. Xiao Yu @HypertextRanch me@xyu.io xyu.io xyu    

    Code Wrangler — Automattic
  3.  

  4.  Does It Scale?

  5.  18,600,000,000 Page Views

  6.  18,600,000,000
 409,000,000 Page Views
 Unique Visitors

  7.  18,600,000,000
 409,000,000 56,000,000 Page Views
 Unique Visitors
 New Posts

  8.  18,600,000,000
 409,000,000 56,000,000
 68,000,000 Page Views
 Unique Visitors
 New

    Posts
 New Comments
  9.  18,600,000,000
 409,000,000 56,000,000
 68,000,000 5,000 Page Views
 Unique Visitors


    New Posts
 New Comments
 Deploys
  10.  18,600,000,000
 409,000,000 56,000,000
 68,000,000 5,000
 1 Page Views
 Unique

    Visitors
 New Posts
 New Comments
 Deploys
 WordPress Multisite
  11.  https://automattic.com/work-with-us/

  12. Anatomy of a Request 

  13. Anatomy of a Request  TCP/IP

  14. Anatomy of a Request  HTTP TCP/IP

  15. Anatomy of a Request  HTTP Application TCP/IP

  16. Anatomy of a Request  HTTP Application Cache TCP/IP

  17. Anatomy of a Request  HTTP Application Cache TCP/IP

  18. Anatomy of a Request  HTTP Application Cache Database /

    Filesystem TCP/IP
  19. Anatomy of a Request  HTTP Application Cache Database /

    Filesystem TCP/IP
  20. Anatomy of a Request  HTTP Application Cache Database /

    Filesystem TCP/IP
  21. Anatomy of a Request  HTTP Application Cache Database /

    Filesystem TCP/IP
  22. Anatomy of a Request  HTTP Application Cache Database /

    Filesystem TCP/IP
  23. Anatomy of a Request  Cache Database / Filesystem Application

    HTTP TCP/IP
  24. Anatomy of a Request 

  25. None
  26. Time to Scale 

  27. Time to Scale  

  28. More Requests / Second

  29. Ways to Scale Software Hardware Be Faster Do More

  30. Ways to Scale Software Hardware Be Faster Optimize Bigger Server

    Do More Async / Multithread More Servers
  31. Ways to Scale Software Hardware Be Faster Optimize Bigger Server

    Do More Async / Multithread More Servers
  32. Ways to Scale Software Hardware Be Faster Optimize Scaling Up

    Do More Async / Multithread More Servers
  33. Ways to Scale Software Hardware Be Faster Optimize Scaling Up

    Do More Async / Multithread Scaling Out
  34. Ways to Scale Software Hardware Be Faster Optimize Scaling Up

    Do More Async / Multithread Scaling Out
  35. Out Not Up 

  36. Out Not Up 

  37. Out Not Up - Amazon vCPU Memory (GB) Cost /

    HR t2.micro 1 1 $0.013
  38. Out Not Up - Amazon vCPU Memory (GB) Cost /

    HR t2.micro 1 1 $0.013 c4.8xlarge 36 60 $1.856
  39. Out Not Up - Amazon vCPU Memory (GB) Cost /

    HR t2.micro 1 1 $0.013 c4.8xlarge 36 60 $1.856 Δ 36x 60x 142x
  40. Out Not Up - Digital Ocean Smallest Largest Δ CPU

    Cores 1 20 20x Memory (GB) 0.5 64 128x Cost / Month $5 $640 128x
  41. None
  42. Out Not Up - Amazon t2.micro c4.8xlarge Δ vCPU 1

    36 36x Memory (GB) 1 60 60x Cost / HR $0.013 $1.856 142x
  43. Out Not Up 

  44. Out Not Up 

  45. Out Not Up 

  46. Out Not Up 

  47. Decoupling & State Cache Database / Filesystem Application HTTP TCP/IP

  48. Decoupling & State  Cache Database / Filesystem Application HTTP

    TCP/IP Cache Database / Filesystem Application HTTP TCP/IP
  49. Decoupling & State State  Stateless
 Application Stateless
 Application

  50. Stateless
 Application Stateless
 Application Decoupling & State State 

  51. Stateless
 Application Stateless
 Application Stateless
 Application Decoupling & State State

    
  52. Stateless
 Application Stateless
 Application Stateless
 Application Stateless
 Application Decoupling &

    State State 
  53. Stateless
 Application Stateless
 Application Stateless
 Application Stateless
 Application Decoupling &

    State State 
  54. Stateless
 Application Stateless
 Application Stateless
 Application Decoupling & State State

    
  55. Decoupling & State Cache Database / Filesystem Application HTTP TCP/IP

  56. Decoupling & State Cache Database / Filesystem Application HTTP TCP/IP

  57. None
  58. None
  59. HTTP Request Headers GET /2015/ HTTP/1.1
 
 Host: maine.wordcamp.org
 Accept:

    text/html,…,image/webp,*/*;q=0.8
 Accept-Language: en-US,en;q=0.8
 Accept-Encoding: gzip, deflate, sdch
 Cache-Control: max-age=0
 Connection: keep-alive
 User-Agent: Mozilla/5.0…
 Cookie: WordPress_test_cookie=…
  60. Decoupling & State Cache Database / Filesystem Application HTTP TCP/IP

  61. Decoupling & State Cache Database / Filesystem PHP & WordPress

    HTTP TCP/IP
  62. PHP & WordPress Are Stateless By Default

  63. PHP & WordPress Are Stateless By Default PHP & WordPress

    Are Stateless By Default*
  64. Local Changes and Uploads Must Be Shared

  65. Local Changes and Uploads Must Be Shared Local Changes and

    Uploads Must Be Shared
  66. You Can Break Statelessness

  67. function initSession() {
 if ( !session_id() ) {
 session_start();
 }


    $_SESSION[ 'my_key' ] = 'value';
 }
 
 add_action( 'init', 'initSession', 1 );
  68. function initSession() {
 if ( !session_id() ) {
 session_start();
 }


    $_SESSION[ 'my_key' ] = 'value';
 }
 
 add_action( 'init', 'initSession', 1 );
  69. Use WordPress CRUD APIs Site Data Post Data User Data

    Short Term Data APIs *_option() *_post_meta() *_user_option()
 *_user_meta() *_transient()
  70. Use WordPress CRUD APIs Site Data Post Data User Data

    Short Term Data APIs *_option() *_post_meta() *_user_option()
 *_user_meta() *_transient() Multisite *_site_option() *_site_transient()
  71. Decoupling & State Cache Database / Filesystem PHP & WordPress

    HTTP TCP/IP 
  72. Decoupling & State Cache Database / Filesystem Application HTTP TCP/IP

  73. Memcached

  74. Decoupling & State Cache Database / Filesystem Application HTTP TCP/IP

  75. HyperDB

  76. Decoupling & State Cache Database / Filesystem Application HTTP TCP/IP

  77. Cache Database / Filesystem Application HTTP TCP/IP 

  78. Cache Database / Filesystem Application HTTP TCP/IP 

  79. Cache Database / Filesystem Application HTTP TCP/IP 

  80. Optimize & Scale Each Layer Individually

  81. – Ron Swanson “Never half-ass two things.
 Whole-ass one thing.”

  82. Optimizations Cache Database / Filesystem Application HTTP TCP/IP

  83. Optimizations

  84. Optimizations Cache Database / Filesystem Application HTTP TCP/IP

  85. Optimizations Photon
 WordPress.com Stats Infinite Scroll Jetpack Comments

  86. Optimizations Cache Database / Filesystem Application HTTP TCP/IP

  87. Optimizations Related Posts
 Publicize Subscriptions Enhanced Distribution

  88. Optimizations Cache Database / Filesystem Application HTTP TCP/IP

  89. Decouple, Optimize, and Scale Out

  90. Thanks! @HypertextRanch me@xyu.io xyu.io xyu    