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

Use setTimeout instead of socket.setTimeout #23

Merged

Conversation

schleyfox
Copy link

We noticed unexpected linear increases in memcached command latency that greatly exceeded the configured timeout value.

Digging in, we realized that the issue is that scoket.setTimeout only triggers the timeoutHandler if the socket has been idle for longer than the timeout. In our case, commands were piling up and we were running a huge queue because an issue increased the latency of each command but not enough to trigger the timeout. All of the commands were long past their deadlines when they were processed, but the socket was never idle long enough to trigger the deadline checking.

This switches the command timeout to regular setTimeout since what the client cares about and wants to guard against is waiting longer than timeout for the command to complete. The fact that bits are flowing is irrelevant. This will cause commands to timeout properly and cause the queue to be flushed, reducing load and allowing new work to be prioritized over already dead work.

We noticed unexpected linear increases in memcached command latency that
greatly exceeded the configured timeout value.

Digging in, we realized that the issue is that scoket.setTimeout only
triggers the timeoutHandler if the socket has been idle for longer than
the timeout. In our case, commands were piling up and we were running a
huge queue because an issue increased the latency of each command but
not enough to trigger the timeout. All of the commands were long past
their deadlines when they were processed, but the socket was never idle
long enough to trigger the deadline checking.

This switches the command timeout to regular setTimeout since what the
client cares about and wants to guard against is waiting longer than
timeout for the command to complete. The fact that bits are flowing is
irrelevant. This will cause commands to timeout properly and cause the
queue to be flushed, reducing load and allowing new work to be
prioritized over already dead work.
Copy link

@leon-root leon-root left a comment

Choose a reason for hiding this comment

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

Approve to unblock, but I am not sure if this will help or not.

@schleyfox
Copy link
Author

@leon-root any reasons you think this will not help? Is it an explanation issue or do you have other concerns?

@leon-root
Copy link

timeout

Oh, I could not understand how it works before.
After Googling, I can understand now, thanks for the improvement.

@schleyfox schleyfox merged commit 6beed35 into master Oct 1, 2024
4 checks passed
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