Latency of flushAndWrite operation

81 views
Skip to first unread message

diamant...@gmail.com

unread,
May 24, 2016, 12:36:43 PM5/24/16
to Netty discussions
Hi, 

I am wondering if anyone can share their insights into netty writeAndFlush latency with me. I am running netty v4.1.0 CR7 with epoll handling about 45,000 QPS of HTTP traffic. Hardware environment is 24 cores with 64GB RAM. Through instrumentation, I am observing a 99th percentile latency of about 10ms for writeAndFlush invocations. I am measuring this by recording the time prior to invoking writeAndFlush and attaching a listener for operationComplete. Does a 10ms 99th percentile latency for writeAndFlush seem reasonable to others? It seems like a significant cost for writing to a socket and I am looking to identify whether or not I can improve my usage of netty.

Thank you,
Michael

Norman Maurer

unread,
May 24, 2016, 2:56:47 PM5/24/16
to ne...@googlegroups.com
Do you write from outside the EventLoop or not? Like calling Channel.writeAndFlush(...) from outside a ChannelHandler implementation?
--
You received this message because you are subscribed to the Google Groups "Netty discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netty+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netty/b5a5d8c2-c3d0-43bf-8a6a-b168daaa57f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

diamant...@gmail.com

unread,
May 25, 2016, 2:11:43 AM5/25/16
to Netty discussions
Hi Norman, 

Thank you for getting back to me.  Yes, in this scenario I am invoking writeAndFlush from outside the EventLoop.

Michael

Arnab Biswas

unread,
Jul 7, 2016, 4:35:32 AM7/7/16
to ne...@googlegroups.com
[Opening an old thread.....]

What is the best practice here? I am assuming that invoking writeAndFlush() from a channelHandler is good (following example) :

public class MyStreamHandler extends ChannelInboundHandlerAdapter {

//Some code 
    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
    //some code

final ChannelFuture future = this.channel.writeAndFlush(content);

future.addListener(new WriteCompleteListener(..);

//some other code
    }

Or  invoking writeAndFlush from outside the EventLoop is the best practice? I am little confused.

Thanks,
Arnab

Reply all
Reply to author
Forward
0 new messages