Skip to content

Instantly share code, notes, and snippets.

@vpnwall-services
Last active May 10, 2023 08:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vpnwall-services/52c776d69bfb4a02083d9d514047f546 to your computer and use it in GitHub Desktop.
Save vpnwall-services/52c776d69bfb4a02083d9d514047f546 to your computer and use it in GitHub Desktop.
[WEB BENCHMARK 101] Web Benchmark 101 #web #benchmark #101 #python #bash

WEB BENCHMARK 101

  • Locust (swarm website with thousands of users) (pip3 install locust)
#locustfile.py
from locust import HttpUser, between, task

class WebsiteUser(HttpUser):
    wait_time = between(5, 15)
    
    def on_start(self):
        self.client.post("/login", {
            "username": "test_user",
            "password": ""
        })
    
    @task
    def index(self):
        self.client.get("/")
        self.client.get("/static/assets.js")
        
    @task
    def about(self):
        self.client.get("/about/")
  • Run locustfile (visit http://127.0.0.1:8089) locust

  • Run headless test locust --headless --users 10 --spawn-rate 1 -H http://your-server.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment