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 Slide

  2. Let's talk about
    performance testing

    View Slide

  3. Why load test?

    View Slide

  4. Common styles of
    performance testing

    View Slide

  5. Stress testing

    View Slide

  6. Spike testing

    View Slide

  7. Endurance testing

    View Slide

  8. Configuration testing

    View Slide

  9. YMMV

    View Slide

  10. Tools

    View Slide

  11. ApacheBench

    View Slide

  12. 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 Slide

  13. 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 Slide

  14. 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 Slide

  15. If you have macOS
    you have ApacheBench

    View Slide

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

    View Slide

  17. h2load

    View Slide

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

    View Slide

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

    View Slide

  20. 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 Slide

  21. 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 Slide

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

    View Slide

  23. JMeter

    View Slide

  24. View Slide

  25. 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 Slide

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

    View Slide

  27. Creating test plans
    is easyish

    View Slide

  28. Don't test production environments
    from your laptop

    View Slide

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

    View Slide

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

    View Slide

  31. Real world
    scenarios

    View Slide

  32. Google Analytics
    is your friend

    View Slide

  33. View Slide

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

    View Slide

  35. Bringing it
    all together

    View Slide

  36. 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 Slide

  37. YMMV

    View Slide

  38. Okay, but
    how many users?

    View Slide

  39. Push it
    to the limit

    View Slide

  40. My limit
    seems kinda low

    View Slide

  41. Questions?

    View Slide

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

    View Slide