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

Scaling WordPress

Scaling WordPress

WordPress is powering some of the biggest publishing sites on the web (CNN.com, techcrunch.com, wired.com). It's no accident that one of best CMSes on the web is chosen to be the publishing platform of choice by these content providers. That said, each of these companies have had to work hard to push the limits of the software to scale to meet the needs of their enormous audiences. In my talk, I will discuss the essential ingredients needed for scaling WordPress to millions of users. This talk will include discussion of integrating external services and technologies along with performant PHP practices to provide a stable publishing experience for the masses.

Zack Tollman

March 15, 2015
Tweet

More Decks by Zack Tollman

Other Decks in Technology

Transcript

  1. SCALING
    WORDPRESS
    with Zack Tollman

    View Slide

  2. View Slide

  3. Slashdot effect
    Digg effect
    Reddit effect
    Farked
    Drudged

    View Slide

  4. Dinner

    View Slide

  5. Celebration

    View Slide

  6. Phone rings

    View Slide

  7. Not at dinner

    View Slide

  8. https://flic.kr/p/pLarbf

    View Slide

  9. Triage
    approach
    to scaling

    View Slide

  10. Stabilize

    View Slide

  11. Diagnose

    View Slide

  12. Treat

    View Slide

  13. Prevent

    View Slide

  14. PAGE CACHING
    Stabilize with

    View Slide

  15. WordPress as a Static Site
    https://flic.kr/p/6bun5f

    View Slide

  16. https://medium.com/message/how-paper-magazines-web-engineers-scaled-kim-kardashians-back-end-sfw-6367f8d37688
    #breaktheinternet

    View Slide

  17. Reduce
    Site Load

    View Slide

  18. Batcache

    View Slide

  19. Varnish

    View Slide

  20. Edge Caching

    View Slide

  21. Tips
    Low TTL to avoid
    invalidation pains

    View Slide

  22. EXPERIENCE
    & TOOLS
    Diagnose with

    View Slide

  23. Database
    Queries

    View Slide

  24. Remote
    Requests

    View Slide

  25. Slow Methods

    View Slide

  26. Query Monitor

    View Slide

  27. Query Monitor

    View Slide

  28. XHProf/XDebug

    View Slide

  29. New Relic

    View Slide

  30. OBJECT
    CACHING
    Treat with

    View Slide

  31. https://flic.kr/p/bxuzPB

    View Slide

  32. WP_Object_Cache
    tollmanz.com/grokking-the-
    wp-object-cache/

    View Slide

  33. Memcached
    github.com/tollmanz/
    wordpress-pecl-memcached-
    object-cache

    View Slide

  34. APC
    wordpress.org/plugins/apc/

    View Slide

  35. WordPress core
    uses object
    caching

    View Slide

  36. wp_cache_set

    View Slide

  37. wp_cache_get

    View Slide

  38. $args = array(

    'number' => 5,

    'username' => 'tollmanz',

    'include_rts' => false,

    );


    $key = md5( $args );

    $group = 'tweets';


    $tweets = wp_cache_get( $key, $group );


    if ( false === $tweets ) {

    $tweets = get_tweets( $args );

    wp_cache_set( $key, $tweets, $group, 600
    );

    }

    View Slide

  39. On Demand

    View Slide

  40. View Slide

  41. View Slide

  42. View Slide

  43. View Slide

  44. Proactive

    View Slide

  45. Proactive
    On save

    View Slide

  46. Proactive
    On scheduled event

    View Slide

  47. Stale While
    Revalidate
    github.com/markjaquith/
    WP-TLC-Transients

    View Slide

  48. Stale While
    Revalidate
    Liveblog

    View Slide

  49. A SOLID
    STACK
    Prevent with

    View Slide

  50. Edge Network

    View Slide

  51. Edge Network
    Load Balancer

    View Slide

  52. Edge Network
    Load Balancer
    Varnish Varnish

    View Slide

  53. Edge Network
    Load Balancer
    Varnish Varnish
    WEB WEB WEB WEB

    View Slide

  54. Edge Network
    Load Balancer
    Varnish Varnish
    WEB WEB WEB ADMIN

    View Slide

  55. Edge Network
    Load Balancer
    Varnish Varnish
    WEB WEB WEB ADMIN
    DB MEM DB MEM

    View Slide

  56. Object cache
    + Page cache
    ———————
    Happy life

    View Slide

  57. Zack Tollman
    @tollmanz
    tollmanz.com/mwphp15

    View Slide