Throtteling for proxies.

Trustin Lee (이희승) trustin at gmail.com
Mon Nov 30 17:36:26 EST 2009


Hi Sebastian,

If setReadable(false) is called, the I/O thread will not read anything
from the channel, which means the data written by the peer (client)
will be stored in the kernel buffer until you resume the read
operation by calling setReadable(true).  If the kernel buffer is full
eventually, the client will be blocked (if in blocking mode) or
nothing will be written until the server reads something.

There is no queue between ChannelHandlers.

HTH

On Fri, Nov 27, 2009 at 11:07 PM, Sebastian Andersson <bofh69 at gmail.com> wrote:
> Hi there!
>
> I've made a proxy with netty. It sits between a server that sends data
> as fast as it can (until its buffers are full) and a client.
> Since the proxy may have a better network connectivity to the server
> than the client has to the proxy, I need to throttle the reading of
> the server's channel, otherwise the client's channel would fill up
> with data.
>
> I'm guessing I would have to solve this with a new class inheriting
> SimpleChannelHandler and overriding writeRequested and writeComplete
> to measure the queue size and call the server's channel's setReadble.
> In this case its important to have an even flow, so I will just change
> the readability for every event depending on the current queue size
> (and I'll have a rather small queue size).
>
> But where does the queue end up? Is there a queue between each
> ChannelHandler? In that case I should perhaps have two such
> ChannelHandlers, one in each end, to prevent a slow protocol encoder
> from building up a queue in the middle of the pipeline.
>
> /Sebastian
> --
> One laptop per child project: http://laptop.org/
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
>


More information about the netty-users mailing list