This project demonstrates a simple Flask application with multiple routes and a Locust-based load testing configuration, all containerized using Docker. The Flask app includes basic routes and a login endpoint, while the Locust configuration is designed to test the app's performance.
- Docker
- Docker Compose
Access the services:
Flask App: The Flask application will be accessible at http://localhost:5000/. Locust UI: The Locust load testing UI will be accessible at http://localhost:8089/. In the Locust UI:
Set the Target Host to http://flask-app:5000. Enter the desired number of users and spawn rate. Click Start Swarming to begin the load test.
How It Works
Flask Application (app.py) The app defines four routes:
/ – Returns "OK". /about – Returns "It's about.". /random – Simulates a random delay (0–2 seconds) and returns "It's late.". /login – A POST route for user authentication, accepting a JSON payload with username and password. The login is validated against a simple in-memory user database defined as USERS.
Locust Load Testing (locustfile.py) Test Routes: Tests the basic /, /about, and /random routes. Test Login: Simulates a login POST request using a predefined username and password (test_user and password123). Docker Compose (docker-compose.yml) Defines two services:
flask-app – The Flask application, accessible on port 5000. locust – The Locust load testing service, accessible on port 8089.
When locust Runs i get page showing as




Finally after performing load testing i can download the report from page it shows the page as below