-
-
Notifications
You must be signed in to change notification settings - Fork 15.9k
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
Detecting actual Channels idleness vs. slowness #6150
Comments
Whether this is a bug or missing feature is open to interpretation ... however if we do want to provide this functionality I don't think we should change the existing default behavior for
It would be good to explore if we can pull this off with existing tools rather than add explicit support for it in the core (unless we think this will drive other useful features). |
@rkapsi @Scottmitch why can't this be fixed by using a |
@normanmaurer it'd work at the expense of garbage. I think for pure idless detection there is a difference in measuring "change" and "progress". And then there's also overall progress and progress in the context of a |
@rkapsi - does the approach I mentioned in #6150 (comment) work for you? |
@Scottmitch - I think No. 1 wouldn't work for the reason you described. No. 2 should work. We'd get the |
Yip. Yah the second bullet is the approach I was referring to ... the first bullet was just to clarify that only using the existing "pending bytes" counter won't be sufficient. |
@Scottmitch want me to look into this? I think it can be added to |
@rkapsi - Sounds good to me. Thanks! |
Motivation The IdleStateHandler tracks write() idleness on message granularity but does not take into consideration that the client may be just slow and has managed to consume a subset of the message's bytes in the configured period of time. Modifications Adding an optional configuration parameter to IdleStateHandler which tells it to observe ChannelOutboundBuffer's state. Result Fixes netty#6150
Motivation The IdleStateHandler tracks write() idleness on message granularity but does not take into consideration that the client may be just slow and has managed to consume a subset of the message's bytes in the configured period of time. Modifications Adding an optional configuration parameter to IdleStateHandler which tells it to observe ChannelOutboundBuffer's state. Result Fixes #6150
Motivation The IdleStateHandler tracks write() idleness on message granularity but does not take into consideration that the client may be just slow and has managed to consume a subset of the message's bytes in the configured period of time. Modifications Adding an optional configuration parameter to IdleStateHandler which tells it to observe ChannelOutboundBuffer's state. Result Fixes netty#6150
Motivation The IdleStateHandler tracks write() idleness on message granularity but does not take into consideration that the client may be just slow and has managed to consume a subset of the message's bytes in the configured period of time. Modifications Adding an optional configuration parameter to IdleStateHandler which tells it to observe ChannelOutboundBuffer's state. Result Fixes netty#6150
I don't know if you'd consider it a missing feature or a bug but there appears to be no effective way of measuring write idleness. The natural choice is to use Netty's own
IdleStateHandler
but it may not work as expected forwrite()
. For the sake of simplicity I'm providing a HTTP example but we encountered it with H2.Basically... The user's (our) intention is to close an idle connection. The
IdleStateHandler
uses the write'sChannelFuture
to determine if a client is idle but it doesn't take into consideration that the client might be just slow and we've just thrown a largeByteBuf
at it. I think we ran into this with H2 due to things likeCoalescingBufferQueue
which try to aggregate multiple writes into a single one.The repro is very simple. You just need to throttle your client a little bit. I'm using Chrome's built-in throtting feature for it. On the server side (the code below) we want to close the connection if the client appears to be idle for 30 seconds.
The problem is that
IdleStateHandler
will make a pure binary decision on the completeness of theChannelFuture
vs. taking actual progression into consideration and it appears there is no API for it.I haven't looked at all
Channel
implementations butNioSocketChannel
andEpollSocketChannel
(viaAbstractEpollStreamChannel
) do have knowledge about the number of bytes written in each cycle. An easy fix could be that channel's sum up these values in avolatile long
field and expose it to the user. Or it could be a simple++
for each write cycle where more than 1 byte was written to the underlying socket. The user could then use it to assess whether or not any or some progress was made between two calls.The text was updated successfully, but these errors were encountered: