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 full-size slide

  2. Slashdot effect
    Digg effect
    Reddit effect
    Farked
    Drudged

    View full-size slide

  3. Not at dinner

    View full-size slide

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

    View full-size slide

  5. Triage
    approach
    to scaling

    View full-size slide

  6. PAGE CACHING
    Stabilize with

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  9. Reduce
    Site Load

    View full-size slide

  10. Edge Caching

    View full-size slide

  11. Tips
    Low TTL to avoid
    invalidation pains

    View full-size slide

  12. EXPERIENCE
    & TOOLS
    Diagnose with

    View full-size slide

  13. Database
    Queries

    View full-size slide

  14. Remote
    Requests

    View full-size slide

  15. Slow Methods

    View full-size slide

  16. Query Monitor

    View full-size slide

  17. Query Monitor

    View full-size slide

  18. XHProf/XDebug

    View full-size slide

  19. OBJECT
    CACHING
    Treat with

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  23. APC
    wordpress.org/plugins/apc/

    View full-size slide

  24. WordPress core
    uses object
    caching

    View full-size slide

  25. wp_cache_set

    View full-size slide

  26. wp_cache_get

    View full-size slide

  27. $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 full-size slide

  28. Proactive
    On save

    View full-size slide

  29. Proactive
    On scheduled event

    View full-size slide

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

    View full-size slide

  31. Stale While
    Revalidate
    Liveblog

    View full-size slide

  32. A SOLID
    STACK
    Prevent with

    View full-size slide

  33. Edge Network

    View full-size slide

  34. Edge Network
    Load Balancer

    View full-size slide

  35. Edge Network
    Load Balancer
    Varnish Varnish

    View full-size slide

  36. Edge Network
    Load Balancer
    Varnish Varnish
    WEB WEB WEB WEB

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  40. Zack Tollman
    @tollmanz
    tollmanz.com/mwphp15

    View full-size slide