I am running htop on the same machine where locust is running. during the tests I have been running this morning, I see one CPU (of 4) hit 100% while the other CPUs are largely idle. I have also observed up to 8 locust tasks running. This is not running distributed. How does locust implement threading and multiprocessing to maximize the available capabilities of the machine?
See https://docs.locust.io/en/stable/running-locust-distributed.html
This applies both for running distributed over multiple machines or just multiple cores.
You need one worker process per core in order to fully utilize the machine.
You can use this bash script for running locust in distributed mode:
echo -e "\nStart LOCUST MASTER\n"
locust -f locust_scenario.py --headless -L $LOG_LEVEL --logfile=$LOG --master-bind-port=$MASTER_PORT \
--master-bind-host=$MASTER_IP -u $COUNT_OF_USERS --print-stats --master --expect-workers=$cores --host=$SERVER_HOST&
PID_MASTER=$!
echo "LOCAST MASTER PID = $PID_MASTER"
sleep 5
# start SLAVE (clients)
echo -e "\nStart LOCUST SLAVES\n"
PID_SLAVES=( )
for ((i = 1; i <= $cores; i++));do
locust -f locust_scenario.py --worker --master-host=$MASTER_IP --master-port=$MASTER_PORT -L $LOG_LEVEL --logfile=$LOG &
PID_SLAVES+=( $! )
done
echo "LOCAST SLAVE PIDs = ${PID_SLAVES[@]}"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With