... locust.

It's nice to know how much traffic your webapp can handle before it gets this amount of traffic for the first time. A tool that can help you calculate this is called locust.

Episode Notes

Here's the flask app that we're running;

# flaskapp.py
from flask import Flask, jsonify
import time 

app = Flask(__name__)

def hello_json():
    return jsonify({"message": "hello world again"})

def hello_sleep():
    return jsonify({"message": "slept"})

Here's the command to run the flask app;

export FLASK_APP=flaskapp.py; flask run --port 8000

Here's the user definition for locust;

import random 
from locust import HttpUser, between, task, tag

class WebsiteUser(HttpUser):
    wait_time = between(1, 1.5)

    def attempt(self):

    def sleep(self):

As a final reminder: think hard about what you would like to benchmark. Otherwise you may risk that you're measuring something that is not that useful for your app.

Feedback? See an issue? Feel free to mention it here.

If you want to be kept up to date, consider getting the newsletter.