netty performance
Marc-André Laverdière
marcandre.laverdiere at gmail.com
Sun Jul 17 10:20:24 EDT 2011
AFAIK nanotime is not very reliable and the javadoc warn of that.
Also, this is not a good test for Netty, as its power really lies in being
able to scale smoothly. For raw performance, you need to remove as many
layers of indirection as possible …
--
Marc-André Laverdiere
Sent from a mobile device. Please excuse the brevity
On 16-Jul-2011 2:44 AM, "akull" <andre.kullmann at googlemail.com> wrote:
> Hi,
>
> I create an simple ping like server/ client application. The client sends
> the system nanos and the server send it back. Now I'm wordering an
roundtrip
> over loopback took 0.2 millis and over lan 1 millsecond. I think this is
> slow. For example an infinispan request/response over lan took 0.8 seconds
> incl. cache lookup and object serialization.
> Is 1 one milli an good time for an netty roundtrip ?
>
> Regards,
> André
>
>
> My Server
>
> public class Netty {
>
> public static void main(String[] args) throws Exception {
>
> ChannelFactory factory =
> new NioServerSocketChannelFactory(
> Executors.newCachedThreadPool(),
> Executors.newCachedThreadPool());
>
> ServerBootstrap bootstrap = new ServerBootstrap(factory);
>
> bootstrap.getPipeline().addLast("handler", new
> SimpleChannelHandler() {
> @Override
> public void messageReceived(ChannelHandlerContext ctx,
> MessageEvent e) throws Exception {
> e.getChannel().write(e.getMessage());
> }
> });
>
> bootstrap.bind(new InetSocketAddress(5555));
> }
> }
>
> My Client
>
> public class NettyClient {
>
> private static double nanosToMillis( double nanos ) {
> double d = ( nanos / (double) 1000 ) / (double) 1000;
> return BigDecimal.valueOf(d).setScale( 5, BigDecimal.ROUND_UP
> ).doubleValue();
> }
>
> public static void main(String[] args) {
>
> ChannelFactory factory = new NioClientSocketChannelFactory(
> Executors.newCachedThreadPool(),
> Executors.newCachedThreadPool() );
>
> ClientBootstrap bootstrap = new ClientBootstrap(factory);
>
> bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
> @Override
> public ChannelPipeline getPipeline() throws Exception {
> return Channels.pipeline(new SimpleChannelUpstreamHandler() {
> @Override
> public void messageReceived( ChannelHandlerContext ctx,
> MessageEvent e) {
>
> long now = System.nanoTime();
> ChannelBuffer buffer = (ChannelBuffer) e.getMessage();
> long time = Bits.getLong( buffer.array(), 0 );
> System.out.println( nanosToMillis(now-time) + "ms.");
> }
> });
> }
> });
>
> ChannelFuture future = bootstrap.connect( new
> InetSocketAddress("localhost", 5555) );
> future.addListener( new ChannelFutureListener() {
>
> @Override
> public void operationComplete( final ChannelFuture future) throws
> Exception {
>
> TimerTask task = new TimerTask() {
> @Override
> public void run() {
> byte[] bytes = new byte[8];
> Bits.putLong(bytes, 0, System.nanoTime() );
> ChannelBuffer msg = ChannelBuffers.copiedBuffer( bytes );
> future.getChannel().write(msg);
> }
> };
>
> new Timer().schedule(task, 0, 1000 );
> }
> });
> }
> }
>
>
> --
> View this message in context:
http://netty-forums-and-mailing-lists.685743.n2.nabble.com/netty-performance-tp6588064p6588064.html
> Sent from the Netty User Group mailing list archive at Nabble.com.
>
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/netty-users/attachments/20110717/9c32f941/attachment.html
More information about the netty-users
mailing list