I am using Python, Docker, and Locust to load test a service I am working on. I have some test data I need to partition uniquely between how ever many docker containers I spin up dynamically. Locust gives all of it's worker containers a name styled as "worker_N". How can I get the worker name assigned to the container by checking inside the python script itself? I am using docker compose to spin up the containers, so I can't use the similar solution provided here.
Asked
Active
Viewed 273 times
1 Answers
0
Depending on exactly what it is you're trying to do, you could set a hostname or maybe an alias for each worker. (Locust uses hostname + a GUID for the name of the workers.) If you need to access each worker somehow, you could set the hostname to include an IP address. Just an idea.
To address your original question more directly, there are also other ways to access hostname, such as in Python code (like Locust does).
One last option would be to use the master do push the data you need to each worker using Locust's messages feature. Then you only need to ensure the master has access to whatever data you want distributed to the workers and it can divvy it up to however many workers are connected.

Solowalker
- 2,431
- 8
- 13