How To Install python3-locust on Ubuntu 22.04

In this tutorial we learn how to install python3-locust on Ubuntu 22.04. python3-locust is Developer friendly load testing framework

Introduction

In this tutorial we learn how to install python3-locust on Ubuntu 22.04.

What is python3-locust

python3-locust is:

Locust is an easy to use, scriptable and scalable performance testing tool. You define the behaviour of your users in regular Python code, instead of using a clunky UI or domain specific language. This makes Locust infinitely expandable and very developer friendly.

Features:

  • Write user test scenarios in plain-old Python – If you want your users to loop, perform some conditional behaviour or do some calculations, you just use the regular programming constructs provided by Python. Locust runs every user inside its own greenlet (a lightweight process/coroutine). This enables you to write your tests like normal (blocking) Python code instead of having to use callbacks or some other mechanism. Because your scenarios are “just python” you can use your regular IDE, and version control your tests as regular code (as opposed to some other tools that use XML or binary formats).
  • Distributed & Scalable - supports hundreds of thousands of users – Locust makes it easy to run load tests distributed over multiple machines. It is event-based (using gevent), which makes it possible for a single process to handle many thousands concurrent users. While there may be other tools that are capable of doing more requests per second on a given hardware, the low overhead of each Locust user makes it very suitable for testing highly concurrent workloads.
  • Web-based UI – Locust has a user friendly web interface that shows the progress of your test in real-time. You can even change the load while the test is running. It can also be run without the UI, making it easy to use for CI/CD testing.
  • Can test any system – Even though Locust primarily works with web sites/services, it can be used to test almost any system or protocol. Just write a client for what you want to test, or explore some created by the community.

There are three methods to install python3-locust on Ubuntu 22.04. We can use apt-get, apt and aptitude. In the following sections we will describe each method. You can choose one of them.

Install python3-locust Using apt-get

Update apt database with apt-get using the following command.

sudo apt-get update

After updating apt database, We can install python3-locust using apt-get by running the following command:

sudo apt-get -y install python3-locust

Install python3-locust Using apt

Update apt database with apt using the following command.

sudo apt update

After updating apt database, We can install python3-locust using apt by running the following command:

sudo apt -y install python3-locust

Install python3-locust Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Ubuntu. Update apt database with aptitude using the following command.

sudo aptitude update

After updating apt database, We can install python3-locust using aptitude by running the following command:

sudo aptitude -y install python3-locust

How To Uninstall python3-locust on Ubuntu 22.04

To uninstall only the python3-locust package we can use the following command:

sudo apt-get remove python3-locust

Uninstall python3-locust And Its Dependencies

To uninstall python3-locust and its dependencies that are no longer needed by Ubuntu 22.04, we can use the command below:

sudo apt-get -y autoremove python3-locust

Remove python3-locust Configurations and Data

To remove python3-locust configuration and data from Ubuntu 22.04 we can use the following command:

sudo apt-get -y purge python3-locust

Remove python3-locust configuration, data, and all of its dependencies

We can use the following command to remove python3-locust configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge python3-locust

References

Summary

In this tutorial we learn how to install python3-locust package on Ubuntu 22.04 using different package management tools: apt, apt-get and aptitude.