Skip to content

Conversation

@MichaelFoleyFZ
Copy link

Locust works great in scalable container environments like ECS which has different ways to allow for the workers to talk to master nodes. One option is Service Connect/Envoy Proxy, this adds a host file entry for a service name for both IPv4 and IPv6 based comms. Except while the OS might have an Ipv6 address the added entry can't be resolved and so the connection fails.

See aws/amazon-ecs-service-connect-agent#120 for a more detailed rundown of the findings for this

This PR allows you to force IPv4 as the preferred option instead of the current setup which prefers IPv6 if the provided hostname resolves to an IPv6 address.

This can be configured using the --master-ipv4-only argument and will apply to both master and workers

@MichaelFoleyFZ MichaelFoleyFZ force-pushed the add-master-ipv4-option branch 4 times, most recently from 3824523 to 1201710 Compare October 26, 2025 11:26
@cyberw
Copy link
Collaborator

cyberw commented Oct 26, 2025

In general, I see the need for this feature, so I like the PR. However:

  • There's some arbitrary whitespace changes in the docs. Nice change, but should be a separate commit to not pollute the git blame history (also your commit message is strange - probably wanna lead with what you've actually changed, not with "Locust works great..." :)
  • I think the Locust worker zmq Client will fall back to ipv4 automatically. Can you try it in your environment? That would make the implementation a bit simpler.

@MichaelFoleyFZ MichaelFoleyFZ force-pushed the add-master-ipv4-option branch 2 times, most recently from b734fef to 228bd45 Compare October 26, 2025 22:32
can be used to work around potential ipv6 issues in
deployed environments
@MichaelFoleyFZ
Copy link
Author

MichaelFoleyFZ commented Oct 26, 2025

In general, I see the need for this feature, so I like the PR. However:

  • There's some arbitrary whitespace changes in the docs. Nice change, but should be a separate commit to not pollute the git blame history (also your commit message is strange - probably wanna lead with what you've actually changed, not with "Locust works great..." :)

fixed up the whitespace removal, my vscode setup code was configured to do it automatically and have fixed up the git commit. Should have been the PR description

  • I think the Locust worker zmq Client will fall back to ipv4 automatically. Can you try it in your environment? That would make the implementation a bit simpler.

The client was the one that was causing my issue, the worker was the one that was resolving the IPv6 address to get to the master. The use_ipv4 function seems to be used by both client and server as its performed in the BaseSocket class, it probably doesn't need to be in the master config since you can control it with bind, but since they both had a consistent setup I figured it would be easier to say you could just set the ipv4 only flag on both to ensure its consistent.

@cyberw
Copy link
Collaborator

cyberw commented Oct 27, 2025

Did you try using export ZMQ_IPV6=0? That seems to be the standard way for disabling ipv6 in zmq.

@MichaelFoleyFZ
Copy link
Author

MichaelFoleyFZ commented Oct 27, 2025

Did you try using export ZMQ_IPV6=0? That seems to be the standard way for disabling ipv6 in zmq.

Set the the env var and updated to use the hostname but looks like it doesn't apply

[2025-10-27 22:34:33,241] ip-10-0-30-5/INFO/locust.runners: Failed to connect to master master.devops-hyena-loadtest:5557, retry 15/60.

I'm guessing if there is an explicit config on the socket that wins?
https://github.com/locustio/locust/blob/2d21010ebb2064d0ff02b17b8a9c4e9138e8ec1a/locust/rpc/zmqrpc.py#L22C3-L22C4

Would it be better to remove the IPv6 handling in locust if zeromq offers those env vars?

@cyberw
Copy link
Collaborator

cyberw commented Nov 1, 2025

Would it be better to remove the IPv6 handling in locust if zeromq offers those env vars?

I think it might be. At the very least we can change that line of code to also respect the zeromq env var?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants