Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding TCP Keep Alive to guarantee master-slave communication #740

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions locust/rpc/zmqrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ class Server(BaseSocket):
def __init__(self, host, port):
context = zmq.Context()
self.receiver = context.socket(zmq.PULL)
self.receiver.setsockopt(zmq.TCP_KEEPALIVE, 1)
self.receiver.setsockopt(zmq.TCP_KEEPALIVE_IDLE, 30)
Copy link
Member

@heyman heyman Mar 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to set TCP_KEEPALIVE_IDLE explicitly here, or could we remove it and let the OS default be used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could use a bit of both.

In order for Locust to function properly, you need to enable TCP Keep Alive even if it is disabled as an OS default setting.

However, the Keep Alive Idle time is a different story. In my case, my environment firewall Idle Time value was shorter than OS default, hence I needed to make it explicitly shorter.

Alternatively, we could add another optional command line parameter to set TCP_KEEPALIVE_IDLE when needed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok! I don't see how it could have any impact on the performance so it's probably fine to set it to 30.

Unless there are cases where turning on keep-alives could have any negative effect, I'd prefer to not expose an additional command line option.

self.receiver.bind("tcp://%s:%i" % (host, port))

self.sender = context.socket(zmq.PUSH)
self.sender.setsockopt(zmq.TCP_KEEPALIVE, 1)
self.sender.setsockopt(zmq.TCP_KEEPALIVE_IDLE, 30)
self.sender.bind("tcp://%s:%i" % (host, port+1))


Expand Down