This repository contains reports of load capacity of a simple Flask API deployed using different configurations:
-
Single instance:
py app.py
The most basic form of flask server running in your local machine. -
Using a load balancer built with flask: It distributes the load in a random manner.
-
Using a load balancer built with flask: It distributes the load in a cyclic manner (Similar to round robin algorithm).
-
Gunicorn: Using 5 gunicorn workers. The number of workers is decided by 2
$\times$ Cores + 1. -
Gunicorn: Using 10 gunicorn workers. It is twice the recomeneded value.
First clone the repository:
git clone https://github.com/Sriram-bb63/maximising-flask-performance.git
To run a single instance:
py instances/app1.py
To run the load balancer:
chmod +x run.sh
./run.sh
py load_balancer.py
To change between cyclic mode and random mode, open
load_balancer.py
and comment/uncomment the respective code blocks.
To run using Gunicorn:
gunicorn instances.app1:app
- Max concurrent users: 1000
- User spawn rate: 100
- Time period: 1 minute
Total requests | Requests/sec | Failures/sec | |
---|---|---|---|
Single instance | 9871 | 164.3 | 1.4 |
Load balancer (Random URL) | 4788 | 79.7 | 4.5 |
Load balancer (Cyclic URL) | 4125 | 68.8 | 3.7 |
Gunicorn (5 workers [Recommended for 2 cores]) | 16335 | 271.8 | 0.0 |
Gunicorn (10 workers [2x recommened value]) | 13443 | 223.8 | 0.0 |