Skip to content

Sriram-bb63/maximising-flask-performance

Repository files navigation

Load testing Flask API

This repository contains reports of load capacity of a simple Flask API deployed using different configurations:

  1. Single instance: py app.py The most basic form of flask server running in your local machine.

  2. Using a load balancer built with flask: It distributes the load in a random manner.

  3. Using a load balancer built with flask: It distributes the load in a cyclic manner (Similar to round robin algorithm).

  4. Gunicorn: Using 5 gunicorn workers. The number of workers is decided by 2 $\times$ Cores + 1.

  5. Gunicorn: Using 10 gunicorn workers. It is twice the recomeneded value.

How to run

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

Traffic

  • Max concurrent users: 1000
  • User spawn rate: 100
  • Time period: 1 minute

Result

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

Detailed reports

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published