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

Scaling WordPress With Load Testing

Scaling WordPress With Load Testing

Everybody wants their site to be scalable. From shared hosting customers to large media companies on expensive dedicated hardware, people deserve to get every last bit of performance that they’ve paid for.

However, most people don’t even bother to load test their sites. And of those who do, a number tend to only run basic tests on their local machine. To truly understand what you can reasonably expect, you need to throw real traffic (and real scenarios) at your production environment.

In this session, we will discuss how to generate tests that mimic realistic user traffic, ways to run these tests against your site, and what to do after you realize things maybe aren’t as fast as you’d thought.

Jason Cosper

October 21, 2016
Tweet

More Decks by Jason Cosper

Other Decks in Technology

Transcript

  1. Scaling WordPress
    With Load Testing
    https://boogah.org/wcsac16

    View full-size slide

  2. Let's talk about
    performance testing

    View full-size slide

  3. Why load test?

    View full-size slide

  4. Common styles of
    performance testing

    View full-size slide

  5. Stress testing

    View full-size slide

  6. Spike testing

    View full-size slide

  7. Endurance testing

    View full-size slide

  8. Configuration testing

    View full-size slide

  9. ApacheBench Gotchas
    » Single threaded.
    » Not good for benchmarking high capacity servers.
    » Works best when run from the same server as your site.
    » Can only hit one URL at a time.
    » Not much actionable data.
    » Not a real browser test.
    » No HTTP/2 support.

    View full-size slide

  10. Using ApacheBench
    ab -n 100 -c 10 https://jasoncosper.com/
    Translation: Have ApacheBench send 100 requests to my site.
    There should be no more than 10 requests running concurrently.

    View full-size slide

  11. ApacheBench Output
    Server Software: nginx
    Server Hostname: jasoncosper.com
    Server Port: 443
    SSL/TLS Protocol: TLSv1.2,ECDHE-RSA-AES256-GCM-SHA384,4096,256
    Document Path: /
    Document Length: 31927 bytes
    Concurrency Level: 10
    Time taken for tests: 34.163 seconds
    Complete requests: 100
    Failed requests: 0
    Total transferred: 3253000 bytes
    HTML transferred: 3192700 bytes
    Requests per second: 2.93 [#/sec] (mean)
    Time per request: 3416.350 [ms] (mean)
    Time per request: 341.635 [ms] (mean, across all concurrent requests)
    Transfer rate: 92.99 [Kbytes/sec] received
    Connection Times (ms)
    min mean[+/-sd] median max
    Connect: 244 259 18.5 253 343
    Processing: 483 3015 2104.7 2566 11495
    Waiting: 479 3011 2104.9 2564 11491
    Total: 754 3274 2105.9 2813 11766
    Percentage of the requests served within a certain time (ms)
    50% 2813
    66% 3673
    75% 4369
    80% 4677
    90% 6319
    95% 7818
    98% 9886
    99% 11766
    100% 11766 (longest request)

    View full-size slide

  12. If you have macOS
    you have ApacheBench

    View full-size slide

  13. Installing ApacheBench
    If you're using Ubuntu to do your development work:
    apt install apache2-utils

    View full-size slide

  14. h2load > ApacheBench
    » HTTP/2 and HTTP/1.1 support out-of-the-box!
    » It's multithreaded!
    » Support for more than one URL!

    View full-size slide

  15. h2load Gotchas
    » Limited actionable data.
    » Not a real browser test.
    » Best run from the same server as your site.

    View full-size slide

  16. Using h2load
    h2load -n1000 -c100 -m10 https://jasoncosper.com/ https://jasoncosper.com/podcasts/
    Translation: Have h2load send 500 requests to two URLs with
    100 concurrent clients. And please don't go over 10 concurrent
    streams.

    View full-size slide

  17. h2load Output
    starting benchmark...
    spawning thread #0: 100 total client(s). 500 total requests
    TLS Protocol: TLSv1.2
    Cipher: ECDHE-RSA-AES256-GCM-SHA384
    Server Temp Key: ECDH P-256 256 bits
    Application protocol: h2
    finished in 100.52s, 4.97 req/s, 143.56KB/s
    requests: 500 total, 500 started, 500 done, 500 succeeded, 0 failed, 0 errored, 0 timeout
    status codes: 500 2xx, 0 3xx, 0 4xx, 0 5xx
    traffic: 14.09MB (14776906) total, 208.11KB (213106) headers (space savings 21.04%), 13.86MB (14531900) data
    min max mean sd +/- sd
    time for request: 442.43ms 100.21s 42.23s 26.80s 61.80%
    time for connect: 236.00ms 301.97ms 268.62ms 19.25ms 63.00%
    time to 1st byte: 678.74ms 46.08s 13.66s 9.60s 69.00%
    req/s : 0.05 0.12 0.07 0.02 74.00%

    View full-size slide

  18. Installing h2load
    https://boogah.org/inst-h2load

    View full-size slide

  19. Apache JMeter
    » Created to test production web apps.
    » Ridiculously configurable and extendable.
    » Cross-platform (Mac, Windows, Linux)
    » Fully multithreaded.
    » GUI and CLI.
    » Distributed remote testing support.

    View full-size slide

  20. Installing JMeter
    https://boogah.org/inst-jmeter

    View full-size slide

  21. Creating test plans
    is easyish

    View full-size slide

  22. Don't test production environments
    from your laptop

    View full-size slide

  23. Flood IO
    https://flood.io/

    View full-size slide

  24. BlazeMeter
    https://www.blazemeter.com/

    View full-size slide

  25. Real world
    scenarios

    View full-size slide

  26. Google Analytics
    is your friend

    View full-size slide

  27. Useful Filters
    » ?s
    » product
    » category
    » tag

    View full-size slide

  28. Bringing it
    all together

    View full-size slide

  29. WooCommerce Test Plans
    » Browse site.
    » Browse site, perform multiple searches.
    » Add products to cart, check out.
    » Log in, browse site.
    » Log in, visit "My Account" page.
    » Log in, add products to cart, check out.

    View full-size slide

  30. Okay, but
    how many users?

    View full-size slide

  31. Push it
    to the limit

    View full-size slide

  32. My limit
    seems kinda low

    View full-size slide

  33. @boogah
    https://jasoncosper.com/
    https://hipsum.co/

    View full-size slide