Once a Website, API, or App is developed, there is often a need to start testing performance. Another useful aspect of Load testing is to start building out operating cost models as you develop pricing for example.
Let's jump in and get started…
From a terminal: run
pip install locust
locust -f locust.py
loadtest % locust -f locust.py
[2021–01–06 09:58:29,316] mbp.lan/INFO/locust.main: Starting web interface at http://0.0.0.0:8089 (accepting connections from all network interfaces)
[2021–01–06 09:58:29,322] mbp.lan/INFO/locust.main: Starting Locust 2.5.1
Open a Web browser and visit this page
http://localhost:8089/
Start a new load test
Set the number of total users to simulate
Set the spawn rate
Set the host
Start swarming
Details on the file below — locust.py
import time
from locust import HttpUser, task, between
class WebsiteUser(HttpUser):
wait_time = between(1, 5)
@task
def index_page(self):
self.client.get(url=”/hello”)
@task
def slow_page(self):
self.client.get(url=”/testsite”)
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)