Load Testing with Locust.io

Guide to load testing with Loucust.io with an H2O wave application

Image credit: https://atmc.in/wp-content/uploads/2017/04/performance-management-in-the-digital-age.png

Recently I got a little task to build a Wave application to test load for API endpoints. After doing some research, found an open-source tool for testing the load easily. I thought it would be beneficial for me and someone who is getting started with Locust.io to keep my findings and the implementation of my Wave application in a documented manner.

H2O Wave is a software stack for building beautiful, low-latency, real-time, browser-based applications and dashboards entirely in Python without using HTML, Javascript, or CSS

Locust is an open-source, easy-to-use, scriptable and scalable performance testing tool.

This is a simple app to test the load for https://www.bbc.com with H2O wave framework and Locust. 3 endpoints have been used for the demonstration.

Quickstart

Prerequisites :

  1. You need to have Python 3.6+ in your Linux, macOS, and Windows in order to install H2O wave.
  2. Need git installed.

Steps :

H2O wave installation and start the wave server

  1. Download and extract the H2O Wave SDK for your platform using — https://github.com/h2oai/wave/releases/tag/v0.19.0
  2. Move it to a convenient location. ($HOME/wave/)
  3. Go to your Wave directory and open a new terminal. Start the wave server using,
./waved

Setup the application

Open a new terminal and create a directory for wave applications. ($HOME/wave-apps/)

mkdir $HOME/wave-apps
cd $HOME/wave-apps

Clone the repository and go inside the folder.

git clone https://github.com/bhanukad610/load-testing-app
cd load-testing-app

Set up a virtual environment

python3 -m venv venv
source venv/bin/activate

Install the dependencies

pip install -r dependencies/requirements.txt

Start the Load testing wave application

wave run src/test_app.py

Open a new terminal in the same directory and start the locust server.

./startLocust.sh

Go to http://localhost:10101/app to access the application.

User Manual to the application

The home page of the application is as follows. You can press the Start button to proceed to the load testing.

Then you will get the below page asking inputs.

  1. Number of users: number of users you need to simulate
  2. Spawn rate: the speed at which users are created in the beginning until the specified number of concurrent users are created
  3. Host: host to load test(it will be filled as ‘https://www.bbc.com‘ for you)

Then you proceed to the Locust dashboard. It has the following tabs.

Statistics

This shows real-time statistics on how the server responds to the requests sent by Locust. For this 3 endpoints have been used and defined in the src/locust.py.

Charts

This shows the charts about total requests per second, response time, and the number of users with time.

Failures

If any request got failed due to a connection error, timeout, page not found, bad request, or similar reason, it will be displayed in this tab.

Exceptions

If the code generates Exceptions, it is recorded in the Exceptions tab during execution.

Tasks

Displays the tasks defined in the locust file.

Download Data

After finishing the test, we can download the data of statistics, failures, and exceptions as CSV files and a report displayed in the web interface.

You can get the source code from,

GitHub – bhanukad610/load-testing-app: A simple app to test the load for a given API with H2O ai wave framework

I hope you got an idea about how to use Locust.io for test load for an API. Thank you for reading!

References


Load Testing with Locust.io was originally published in Level Up Coding on Medium, where people are continuing the conversation by highlighting and responding to this story.


This content originally appeared on Level Up Coding - Medium and was authored by Bhanuka Dissanayake

Guide to load testing with Loucust.io with an H2O wave application

Image credit: https://atmc.in/wp-content/uploads/2017/04/performance-management-in-the-digital-age.png

Recently I got a little task to build a Wave application to test load for API endpoints. After doing some research, found an open-source tool for testing the load easily. I thought it would be beneficial for me and someone who is getting started with Locust.io to keep my findings and the implementation of my Wave application in a documented manner.

H2O Wave is a software stack for building beautiful, low-latency, real-time, browser-based applications and dashboards entirely in Python without using HTML, Javascript, or CSS

Locust is an open-source, easy-to-use, scriptable and scalable performance testing tool.

This is a simple app to test the load for https://www.bbc.com with H2O wave framework and Locust. 3 endpoints have been used for the demonstration.

Quickstart

Prerequisites :

  1. You need to have Python 3.6+ in your Linux, macOS, and Windows in order to install H2O wave.
  2. Need git installed.

Steps :

H2O wave installation and start the wave server

  1. Download and extract the H2O Wave SDK for your platform using — https://github.com/h2oai/wave/releases/tag/v0.19.0
  2. Move it to a convenient location. ($HOME/wave/)
  3. Go to your Wave directory and open a new terminal. Start the wave server using,
./waved

Setup the application

Open a new terminal and create a directory for wave applications. ($HOME/wave-apps/)

mkdir $HOME/wave-apps
cd $HOME/wave-apps

Clone the repository and go inside the folder.

git clone https://github.com/bhanukad610/load-testing-app
cd load-testing-app

Set up a virtual environment

python3 -m venv venv
source venv/bin/activate

Install the dependencies

pip install -r dependencies/requirements.txt

Start the Load testing wave application

wave run src/test_app.py

Open a new terminal in the same directory and start the locust server.

./startLocust.sh

Go to http://localhost:10101/app to access the application.

User Manual to the application

The home page of the application is as follows. You can press the Start button to proceed to the load testing.

Then you will get the below page asking inputs.

  1. Number of users: number of users you need to simulate
  2. Spawn rate: the speed at which users are created in the beginning until the specified number of concurrent users are created
  3. Host: host to load test(it will be filled as ‘https://www.bbc.com' for you)

Then you proceed to the Locust dashboard. It has the following tabs.

Statistics

This shows real-time statistics on how the server responds to the requests sent by Locust. For this 3 endpoints have been used and defined in the src/locust.py.

Charts

This shows the charts about total requests per second, response time, and the number of users with time.

Failures

If any request got failed due to a connection error, timeout, page not found, bad request, or similar reason, it will be displayed in this tab.

Exceptions

If the code generates Exceptions, it is recorded in the Exceptions tab during execution.

Tasks

Displays the tasks defined in the locust file.

Download Data

After finishing the test, we can download the data of statistics, failures, and exceptions as CSV files and a report displayed in the web interface.

You can get the source code from,

GitHub - bhanukad610/load-testing-app: A simple app to test the load for a given API with H2O ai wave framework

I hope you got an idea about how to use Locust.io for test load for an API. Thank you for reading!

References


Load Testing with Locust.io was originally published in Level Up Coding on Medium, where people are continuing the conversation by highlighting and responding to this story.


This content originally appeared on Level Up Coding - Medium and was authored by Bhanuka Dissanayake


Print Share Comment Cite Upload Translate Updates
APA

Bhanuka Dissanayake | Sciencx (2021-11-26T15:33:58+00:00) Load Testing with Locust.io. Retrieved from https://www.scien.cx/2021/11/26/load-testing-with-locust-io/

MLA
" » Load Testing with Locust.io." Bhanuka Dissanayake | Sciencx - Friday November 26, 2021, https://www.scien.cx/2021/11/26/load-testing-with-locust-io/
HARVARD
Bhanuka Dissanayake | Sciencx Friday November 26, 2021 » Load Testing with Locust.io., viewed ,<https://www.scien.cx/2021/11/26/load-testing-with-locust-io/>
VANCOUVER
Bhanuka Dissanayake | Sciencx - » Load Testing with Locust.io. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/11/26/load-testing-with-locust-io/
CHICAGO
" » Load Testing with Locust.io." Bhanuka Dissanayake | Sciencx - Accessed . https://www.scien.cx/2021/11/26/load-testing-with-locust-io/
IEEE
" » Load Testing with Locust.io." Bhanuka Dissanayake | Sciencx [Online]. Available: https://www.scien.cx/2021/11/26/load-testing-with-locust-io/. [Accessed: ]
rf:citation
» Load Testing with Locust.io | Bhanuka Dissanayake | Sciencx | https://www.scien.cx/2021/11/26/load-testing-with-locust-io/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.