locustio / locust

Write scalable load tests in plain Python 🚗💨
https://locust.cloud
MIT License
25.11k stars 3k forks source link

Requests not ramping up after switching to using pydantic in django project #2960

Closed davidu1975 closed 2 weeks ago

davidu1975 commented 3 weeks ago

Prerequisites

Description

Hi locust -f tests/load/mvp_home.py --headless -u 100 -r 5 -t 30s -H http://localhost:8020 is not ramping up requests mvp_home.py is

-- coding: utf-8 --

from locust import HttpUser, TaskSet, between, task

class MVPTasks(TaskSet): @task def home_page(self): self.client.get('/')

class MVP(HttpUser): tasks = [MVPTasks] wait_time = between(1, 2)

Command line

locust -f tests/load/mvp_home.py --headless -u 100 -r 5 -t 30s -H http://localhost:8020

Locustfile contents

# -*- coding: utf-8 -*-
from locust import HttpUser, TaskSet, between, task

class MVPTasks(TaskSet):
    @task
    def home_page(self):
        self.client.get('/')

class MVP(HttpUser):
    tasks = [MVPTasks]
    wait_time = between(1, 2)

Python version

3.9.13

Locust version

2.32.1

Operating system

Linux Ubuntu

cyberw commented 3 weeks ago

https://docs.locust.io/en/stable/increasing-request-rate.html

davidu1975 commented 3 weeks ago
It also does not display any requests being made they are all 0 ie- locust --locustfile tests/load/mvp_home.py --users=20 --spawn-rate=3 --run-time=30s --headless --csv=./results/results [2024-11-04 21:16:11,673] c00efda0bef8/INFO/locust.main: Run time limit set to 30 seconds [2024-11-04 21:16:11,673] c00efda0bef8/INFO/locust.main: Starting Locust 2.27.0 Type Name # reqs # fails Avg Min Max Med req/s failures/s
-------- ------- ------------- ------- ------- ------- ------- -------- -----------
Aggregated 0 0(0.00%) 0 0 0 0 0.00 0.00
[2024-11-04 21:16:11,681] c00efda0bef8/INFO/locust.runners: Ramping to 20 users at a rate of 3.00 per second Type Name # reqs # fails Avg Min Max Med req/s failures/s
-------- ------- ------------- ------- ------- ------- ------- -------- -----------
Aggregated 0 0(0.00%) 0 0 0 0 0.00 0.00
Type Name # reqs # fails Avg Min Max Med req/s failures/s
-------- ------- ------------- ------- ------- ------- ------- -------- -----------
Aggregated 0 0(0.00%) 0 0 0 0 0.00 0.00
cyberw commented 3 weeks ago

The log says you are on locust 2.27.0?

davidu1975 commented 3 weeks ago
I have bumped to 2.32.1 locust --locustfile tests/load/mvp_home.py --users=20 --spawn-rate=3 --run-time=30s --headless --csv=./results/results [2024-11-04 23:12:22,865] e2632680112f/INFO/locust.main: Starting Locust 2.32.1 [2024-11-04 23:12:22,865] e2632680112f/WARNING/locust.main: Python 3.9 support is deprecated and will be removed soon [2024-11-04 23:12:22,867] e2632680112f/INFO/locust.main: Run time limit set to 30 seconds Type Name # reqs # fails Avg Min Max Med req/s failures/s
-------- ------- ------------- ------- ------- ------- ------- -------- -----------
Aggregated 0 0(0.00%) 0 0 0 0 0.00 0.00
[2024-11-04 23:12:22,870] e2632680112f/INFO/locust.runners: Ramping to 20 users at a rate of 3.00 per second Type Name # reqs # fails Avg Min Max Med req/s failures/s
-------- ------- ------------- ------- ------- ------- ------- -------- -----------
Aggregated 0 0(0.00%) 0 0 0 0 0.00 0.00
Type Name # reqs # fails Avg Min Max Med req/s failures/s
-------- ------- ------------- ------- ------- ------- ------- -------- -----------
Aggregated 0 0(0.00%) 0 0 0 0 0.00 0.00
Type Name # reqs # fails Avg Min Max Med req/s failures/s
-------- ------- ------------- ------- ------- ------- ------- -------- -----------
Aggregated 0 0(0.00%) 0 0 0 0 0.00 0.00
[2024-11-04 23:12:28,875] e2632680112f/INFO/locust.runners: All users spawned: {"MVP": 20} (20 total users) Type Name # reqs # fails Avg Min Max Med req/s failures/s
-------- ------- ------------- ------- ------- ------- ------- -------- -----------
Aggregated 0 0(0.00%) 0 0 0 0 0.00 0.00
Type Name # reqs # fails Avg Min Max Med req/s failures/s
-------- ------- ------------- ------- ------- ------- ------- -------- -----------
Aggregated 0 0(0.00%) 0 0 0 0 0.00 0.00
andrewbaldwin44 commented 2 weeks ago

Hi @davidu1975, your issue could be reproduced with this simple example:

from flask import Flask
import time

app = Flask(__name__)

@app.route("/")
def home():
    time.sleep(10)
    return "Hello world"

Most likely your server is simply being overloaded and is never responding. Locust users waits for a response from the server before reporting stats. If the server never responds, no stats will be reported. I recommend trying with 1 locust user to start, and slowly ramp up from there. If you're still having trouble debugging your server, try reaching out to us on slack.