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

Un-Scaling WordPress

Un-Scaling WordPress

WordPress can scale from a few visitors per day to millions. While it can be complicated to get WordPress to run in a clustered setup, most sites don’t need this.

While developing WordPress managed hosting, one of the discoveries was that WordPress can not only scale, but it can handle millions of visits per month with a single web machine and MySQL.

I’ll walk through the basics of performance in WordPress, and what it takes to build a highly performing install on a single VPS + MySQL, dispelling the myth that it requires a large amount of resources to handle a huge amount of traffic with WordPress.

Mike Schroder

July 14, 2017
Tweet

More Decks by Mike Schroder

Other Decks in Technology

Transcript

  1. Un-Scaling WordPress
    WordCamp DC 2017
    Mike Schroder
    Director of WordPress Strategy @ DreamHost
    @GetSource - https://getsource.net

    View full-size slide

  2. What does it mean to scale?

    View full-size slide

  3. Vertical scaling:
    More RAM and CPU.

    View full-size slide

  4. Horizontal scaling:
    More servers with the RAM and CPU.

    View full-size slide

  5. Vertical scaling

    View full-size slide

  6. Vertical scaling

    View full-size slide

  7. Horizontal scaling

    View full-size slide

  8. Horizontal scaling

    View full-size slide

  9. What does it mean to un-scale?

    View full-size slide

  10. Simplified architecture.

    View full-size slide

  11. Let’s see what we can do with
    shared and a 512mb VPS.

    View full-size slide

  12. How much RAM does
    WordPress need?

    View full-size slide

  13. Page View => ~3-120mb
    Image Operations => ~256mb+

    View full-size slide

  14. Does WordPress scale?

    View full-size slide

  15. Adjacent technologies help WordPress
    serve higher traffic sites well.

    View full-size slide

  16. We’re really talking about caching.

    View full-size slide

  17. If you’ve hit PHP, you’ve lost.

    View full-size slide

  18. But it’s not as bad as it used to be.

    View full-size slide

  19. Opcode cache.

    View full-size slide

  20. Usually OPcache,
    included with PHP 5.5+

    View full-size slide

  21. Higher percentage of improvement
    on hosts with low CPU resources.

    View full-size slide

  22. Test: ~100 users during 1 minute.

    View full-size slide

  23. Shared PHP 5.6
    100/min
    Average:
    1045ms

    View full-size slide

  24. Shared PHP 5.6 w/OPcache
    100/min
    Average:
    782ms

    View full-size slide

  25. Shared PHP 7
    100/min
    Average:
    760ms

    View full-size slide

  26. Shared PHP 7 w/OPcache
    100/min
    Average:
    507ms

    View full-size slide

  27. Persistent object caching.

    View full-size slide

  28. By default, WP’s internal cache
    expires with each request.

    View full-size slide

  29. Persistent object caching
    helps dynamic sites most.

    View full-size slide

  30. Usually this is
    Memcached or Redis.

    View full-size slide

  31. Front end caching.

    View full-size slide

  32. Save the final output of PHP.

    View full-size slide

  33. Disk, Varnish, Nginx.

    View full-size slide

  34. Front end caching
    helps static sites most.

    View full-size slide

  35. Shared PHP 7 w/OPcache + WP Super Cache
    PHP Routed:
    100/min
    Average:
    69ms

    View full-size slide

  36. Like with “firewall” plugins,
    treat PHP-based solutions
    with skepticism.

    View full-size slide

  37. Shared PHP 7 w/OPcache + WP Super Cache
    Disk Backed:
    100/min
    Average:
    32ms

    View full-size slide

  38. Shared PHP 7 w/OPcache + WP Super Cache
    Disk Backed:
    1000/min
    Average:
    43ms

    View full-size slide

  39. Shared PHP 7 w/OPcache + WP Super Cache
    Disk Backed:
    5000/min
    Average:
    2158ms

    View full-size slide

  40. Let’s take a look at our VPS.

    View full-size slide

  41. VPS PHP 7 w/OPcache
    100/min
    Average:
    169ms

    View full-size slide

  42. VPS PHP 7 w/OPcache + Varnish
    RAM Backed
    100/min
    Average:
    21ms

    View full-size slide

  43. VPS PHP 7 w/OPcache + Varnish
    RAM Backed
    5000/min
    Average:
    17ms

    View full-size slide

  44. 5000/min => 216,000,000/month

    View full-size slide

  45. How much RAM do
    adjacent services need?

    View full-size slide

  46. Basically anything helps for OPcache.
    So have some.

    View full-size slide

  47. 32-96mb for Memcached,
    with slab size > than options.
    (4mb is a good start)

    View full-size slide

  48. 128mb Varnish
    Have some VCL.

    https://github.com/tollmanz/varnish-vcl-collection

    View full-size slide

  49. Thanks!
    Mike Schroder
    @GetSource
    https://getsource.net
    Director of WordPress Strategy @ DreamHost

    View full-size slide