Closed ichsansaid closed 1 week ago
Hi! It sounds like you are running locust in the same process as the thing you are testing? Dont do that!
If necessary, use process.Popen(”locust …”, …) in your application to launch locust in a separate process. But ideally, a load testing tool should never be running on the same machine as the thing you are testing.
Hi! It sounds like you are running locust in the same process as the thing you are testing? Dont do that!
If necessary, use process.Popen(”locust …”, …) in your application to launch locust in a separate process. But ideally, a load testing tool should never be running on the same machine as the thing you are testing.
Hi cyber, thanks for the reply. I hope i can separate the Process with Popen but i can't because i want to get the stats in every 1 second. If i do that in different process, i can't get the stats. So that's why i run Locust as Library
Why cant you get the stats in every second? Maybe you can do gevent.spawn(NewOnLiveStats(on_live_stats), self)
in the test_start
event handler? (idk what NewOnLiveStats is though :)
This issue was closed because it has been stalled for 10 days with no activity. This does not necessarily mean that the issue is bad, but it most likely means that nobody is willing to take the time to fix it. If you have found Locust useful, then consider contributing a fix yourself!
Prerequisites
Description
Hello,
I'm currently developing a Low-Code Development Platform (LCDP) and want to create a pre-built component for performance testing.
I'm using FastAPI as the platform's backend and Locust for performance testing.
I have an API called execute_scenario that executes tasks. For example, I can execute a scenario called "LocustScenario."
My approach is to use Locust as a library. So, each executed scenario of "LocustScenario" will create an environment and start the performance test. I also capture the statistics every second (using gevent.sleep) and send them to our message broker.
However, I'm facing two issues:
First Issue: monkey.patch_all() causes blocking in FastAPI. Therefore, I decided to remove it from the code manually in init.py for now. Second Issue: When I perform a performance test for HTTP, there are no issues. Our message broker receives the messages every second. However, when I perform a performance test for HTTPS, there is a delay of 3-5 seconds (somewhat randomly) when capturing the statistics every second using gevent.sleep(1).
Command line
library
Locustfile contents
Python version
3.12
Locust version
latest
Operating system
windows