Flask API to show the number of requests and API health status.
This is a Flask application that serves as a Request Counter API. It includes a simple web page displaying information about the application, including the request count and health status.
- Show the request count.
- Visualize the health status of the API.
- git
- Container Engine (Docker, ContainerD, Podman etc)
- docker-compose (optional)
- Clone the repository:
git clone https://github.com/alexolinux/flask-requester.git
- Go to the project folder:
cd flask-request
- Build the Docker Image:
docker build -t alexmbarbosa/flask-request:10.0 .
List my docker images:
docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
alexmbarbosa/flask-request 10.0 6a96582e9ffa 1 hours ago 91.8MB
- In this case, I am using the same docker tag/name that I have pushed to my docker hub repository already with this flask-request image. Feel free to use any name for your tag/image.
How about simulating a few load tests?
It is possible to use a useful Python tool called Locust. For this, let's use our flask-request
and the official locust
docker image (Access Locust on Docker for more details).
- Spin Up
flask-request
container:
docker run --rm --name flask-request -p 5000:5000 alexmbarbosa/flask-request:10.0
Open your flask-request
page accessing http://localhost:5000 (or you local IP address (containers are binding to 0.0.0.0:PORT
))
- Now, Spin Up
locust
container:
docker run --rm --name locust -p 8089:8089 -v $(pwd):/locust locustio/locust -f /locust/locustfile.py --host http://localhost:5000
Open your locust
page accessing http://localhost:8089 (or you local IP address (containers are binding to 0.0.0.0:PORT
))
Locust Docs: https://docs.locust.io/en/stable/quickstart.html
Additionally, I am providing a docker-compose.yml
simplifying the deployment of docker containers.
Just run:
docker-compose up
Now, you can make your custom workload tests.
Have fun!