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

Load Testing with Locust.io

Avatar for James Carr James Carr
October 04, 2016

Load Testing with Locust.io

Avatar for James Carr

James Carr

October 04, 2016

More Decks by James Carr

Other Decks in Technology

Transcript

  1. TONIGHT ➤ Brief discussion on load testing ➤ Introduction to

    locust.io ➤ Quickstart Demo + Distributed Demo ➤ In depth details ➤ More Demos! ➤ load testing non-http services ➤ using influxDB + Grafana to graph response times
  2. PROVISIONING ➤ Without load testing, we’re left to make educated

    guesses ➤ sometimes we can reason about capacity by performing canaries, then applying mathematics ➤ Even so, it’s good to know when the breaking point is of a single service ➤ and be able to scale out accordingly ➤ Being able to scientifically prove limits and responsiveness is very important!
  3. SOME UNMET NEEDS ➤ Want to be able to write

    in the language we primarily develop in (python) ➤ Also wanted to leverage existing client code ➤ Even use auth details from Vault ➤ Want to test non-http services (rabbitmq, memcached, kafka, etc.) ➤ Be able to easily spin up a swarm on EC2 ➤ A dashboard GUI of some kind would be a little nice too
  4. LOUST.IO ➤ found randomly while looking for a good tool

    to benchmark mcrouter + N memcached boxes ➤ Tests are written completely in python ➤ Very Flexible… can do anything you can do in python ➤ Can do multi-step tests ➤ e.g. login, set and get this value, etc. ➤ Can run in a distributed environment with many workers
  5. THE LOCUST CLASS ➤ Locust - represents a single user.

    Locust will spawn one instance of the class for each user being simulated ➤ `task_set` - points to a TaskSet class that defines the behavior of the user ➤ min_wait and max_wait - the minimum and maximum time a user may wait between requests, randomized
  6. TASKSET ➤ Methods decorated with @task are executed ➤ providing

    a number to @task will weight it ➤ task1 will run more often than task2 ➤ on_start - called when a simulated user starts the TaskSet
  7. HTTPLOCUST ➤ The HttpLocust contains convenience methods for interacting over

    http ➤ self.client - HttpSession implementation of requests.Session ➤ The source code of this is a GREAT place to read if you want to extend Locust to support non-http protocols
  8. WORKING WITH EVENTS ➤ locust.events - fire events on various

    different things ➤ can be appended to quite easily to add handlers
  9. ➤ Obviously there’s a lot of interesting things we can

    do with event handling ➤ Very crucial if you make your own custom Locust class to define startup / shutdown behaviors ➤ One interesting way to use them: building a custom metric collection mechanism.
  10. CLOSING THOUGHTS ➤ Use docker-swarm + EC2 for quick load

    test swarming ➤ Some rough edges… more built for hacking versus declaratively defining tests ➤ https://github.com/jamescarr/locust.io-demo ➤ Questions?