Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using multi-CPU platforms with locust

Tags:

locust

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?enter image description here

like image 616
Chris Hare Avatar asked Jun 03 '20 12:06

Chris Hare


2 Answers

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.

like image 87
Cyberwiz Avatar answered Oct 03 '22 07:10

Cyberwiz


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[@]}"
like image 39
Alexaxndr Lyakhov Avatar answered Oct 03 '22 06:10

Alexaxndr Lyakhov