Locust

Contents
Introduction
Quick Start trial run
Locust articles in order

Introduction

In this article series you will learn how to organize load testing in Python 3 with the Locust library.

It is assumed that you work in Ubuntu Linux but that is optional.

I have aliases python - python3 and pip - pip3 set up, so I do not write the trailing 3.

The aliases article «Bash Python alias» is available at this link .

Quick Start

To run the simplest variant, create a locustfile.py file and copy the following code into it ( source )

import time from locust import HttpUser, task, between class QuickstartUser(HttpUser): wait_time = between(1, 2) @task def index_page(self): self.client.get("/hello") self.client.get("/world") @task(3) def view_item(self): for item_id in range(10): self.client.get(f"/item?id={item_id}", name="/item") time.sleep(1) def on_start(self): self.client.post("/login", json={"username":"foo", "password":"bar"})

Go to the same directory as locustfile.py and run the command

locust

Oct 27 18:53:45 andrei-ubuntu/INFO/locust.main: Starting web interface at http://0.0.0.0:8089 (accepting connections from all network interfaces) Oct 27 18:53:45 andrei-ubuntu/INFO/locust.main: Starting Locust 1.3.1

If locust complains:

Oct 27 18:53:45 andrei-ubuntu/WARNING/locust.main: System open file limit '1024' is below minimum setting '10000'. It's not high enough for load testing, and the OS didn't allow locust to increase it by itself. See https://github.com/locustio/locust/wiki/Installation#increasing-maximum-number-of-open-files-limit for more info.

Read the solution here

Article author: Andrei Olegovich

Related articles
Locust
Getting started with Locust
Install Locust
Launch options --help
Locust errors
Install Locust in PyCharm
Software Testing
REST API with Python
Python
Pip
Flask

Search this site

Subscribe to Telegram channel @aofeed to follow new articles and updates to old ones

Go to channel

@aofeed

Ask a question in the Telegram group

@aofeedchat

Contacts and cooperation:
I recommend our hosting beget.com
Write to info@aredel.com if you:
1. Want to write an article for our site or translate an article into your native language.
2. Want to place thematically relevant ads on the site.
3. Ads on my site pass maximum censorship. If you see an ad block unsuitable for school-age children, shocking or misleading - please contact us by e-mail
4. Found a mistake, inaccuracy, bug, etc. on the site. ... .......
5. Articles can be shared on social media by clicking a network icon: