Source: Locust IO
It's quite simple to install locustio :
pip install locustio
Next, we create a simple scenario which will realize the following operations (with differents methods) :
- Call https://mydomain.com
- Call https://mydomain.com/pdf/a-file.pdf
- Call https://mydomain.com/an-article.html
from locust import HttpLocust, TaskSet, task import resource def get_index(l): l.client.get("/") def get_pdf(l): l.client.get("/pdf/a-file.pdf") class UserTasks(TaskSet): resource.setrlimit(resource.RLIMIT_NOFILE, (999999, 999999)) # Using an array tasks = [get_index, get_pdf] # Using the task decorator @task(1) def get_article(self): self.client.get("/an-article.html") class WebsiteUser(HttpLocust): """ Locust user class that does requests to the locust web server running on localhost """ host = "http://127.0.0.1:8089" min_wait = 2000 max_wait = 5000 task_set = UserTasks
Please note that the following code is needed to bypass the limit of 1000 users :
resource.setrlimit(resource.RLIMIT_NOFILE, (999999, 999999))
You need to be allowed to launch a benchmark !
First, you launch Locust-IO :
locust -f /my/folder/to/my/script.py --host https://mydomain.com
Please note that your script can't be called locust.py !
Finally, we open a browser to http://ip-local:8089 , and fill :
- Number of users to simulate
- Hatch Rate
And click on Start swarming !