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 Slide

  2. What does it mean to scale?

    View Slide

  3. Vertical scaling:
    More RAM and CPU.

    View Slide

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

    View Slide

  5. Vertical scaling

    View Slide

  6. Vertical scaling

    View Slide

  7. Horizontal scaling

    View Slide

  8. Horizontal scaling

    View Slide

  9. What does it mean to un-scale?

    View Slide

  10. View Slide

  11. Simplified architecture.

    View Slide

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

    View Slide

  13. How much RAM does
    WordPress need?

    View Slide

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

    View Slide

  15. Does WordPress scale?

    View Slide

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

    View Slide

  17. We’re really talking about caching.

    View Slide

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

    View Slide

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

    View Slide

  20. Opcode cache.

    View Slide

  21. Usually OPcache,
    included with PHP 5.5+

    View Slide

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

    View Slide

  23. Test: ~100 users during 1 minute.

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  28. Persistent object caching.

    View Slide

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

    View Slide

  30. Persistent object caching
    helps dynamic sites most.

    View Slide

  31. Usually this is
    Memcached or Redis.

    View Slide

  32. Front end caching.

    View Slide

  33. Save the final output of PHP.

    View Slide

  34. Disk, Varnish, Nginx.

    View Slide

  35. Front end caching
    helps static sites most.

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  46. How much RAM do
    adjacent services need?

    View Slide

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

    View Slide

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

    View Slide

  49. 128mb Varnish
    Have some VCL.

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

    View Slide

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

    View Slide