Calmcode - locust: break

How to run Locust until the webapp breaks.

1 2 3 4 5 6 7 8

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

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 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.