Handling HTTP/2 streams concurrently

53 views
Skip to first unread message

Johnson Li

unread,
Sep 1, 2017, 2:09:22 AM9/1/17
to Netty discussions
Hi,

I have used Netty as an HTTP/2 server for a period of time and found that it did not take full advantage of HTTP/2 multiplexing. What I mean is that Netty handles all HTTP/2 streams in one thread if they come from the same TCP connection. But that is not expected because HTTP/2 merges multiple TCP connections into one, and let the HTTP/2 to handle the concurrency. So the application handler should run concurrently to handle concurrent HTTP/2 streams.

One simple phenomenon is that if I set up an HTTP/2 client and an HTTP/2 server, letting the client sends requests quickly. But the CPU usage of the server will never exceed 100%, which means it only uses one CPU core. That will cause performance issues if the server is busy with making responses.

Any thoughts?

Johnson

Rogan Dawes

unread,
Sep 1, 2017, 2:27:27 AM9/1/17
to Netty discussions
Use a separate workerGroup to run the final handler?


 ChannelPipeline pipeline = ch.pipeline();

 pipeline.addLast("decoder", new MyProtocolDecoder());
 pipeline.addLast("encoder", new MyProtocolEncoder());

 // Tell the pipeline to run MyBusinessLogicHandler's event handler methods
 // in a different thread than an I/O thread so that the I/O thread is not blocked by
 // a time-consuming task.
 // If your business logic is fully asynchronous or finished very quickly, you don't
 // need to specify a group.
 pipeline.addLast(group, "handler", new MyBusinessLogicHandler());
Rogan

--
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/9a11955a-b0cf-4998-9b9f-d6f1335d3965%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Johnson Li

unread,
Sep 1, 2017, 3:17:48 AM9/1/17
to Netty discussions, ro...@dawes.za.net

Thank you a lot, that works great for me.
Reply all
Reply to author
Forward
0 new messages