High Performance JVM Networking with Netty

High Performance JVM Networking with Netty

This talk, given at JDK.io, is an introduction into Netty with lots of real world examples and experiences building clients and servers on top of it. Recording may be found through jdk.io at some point.

D839d9aa56849a71d8a9aa3d292a6ce6?s=128

Michael Nitschinger

September 14, 2016
Tweet

Transcript

  1. JVM Networking with Netty Michael Nitschinger, Couchbase, Inc. High Performance!

  2. None
  3. “Netty is an asynchronous and event-driven network application framework for

    rapid development of maintainable high performance protocol servers & clients.“
  4. “Netty is an asynchronous and event-driven network application framework for

    rapid development of maintainable high performance protocol servers & clients.“
  5. It’s simple.

  6. Half-Duplex Full-Duplex

  7. None
  8. ChannelHandler ChannelHandler ChannelHandler ChannelHandler Pipeline

  9. Encoder Encoder Decoder Decoder

  10. OutboundHandler OutboundHandler InboundHandler InboundHandler

  11. Encoder Encoder Decoder Decoder Codec Codec

  12. BinaryMemcacheObjectAggregator KeyValueAuthHandler KeyValueFeatureHandler BinaryMemcacheClientCodec KeyValueHandler

  13. None
  14. None
  15. None
  16. None
  17. None
  18. “Each Handler receives events from the pipeline and emits events

    into the pipeline.“
  19. None
  20. None
  21. None
  22. None
  23. Handlers Codecs ByteToByte ByteToMessage MessageToByte MessageToMessage Replay FixedLengthFrame LengthFieldBasedFrame LineBasedFrame

    DelimiterBasedFrame …. HTTP HTTP2 Memcache MQTT Redis Smtp SSL Websockets Xml Zlib …
  24. Handlers Codecs ByteToByte ByteToMessage MessageToByte MessageToMessage Replay FixedLengthFrame LengthFieldBasedFrame LineBasedFrame

    DelimiterBasedFrame …. HTTP HTTP2 Memcache MQTT Redis Smtp SSL Websockets Xml Zlib …
  25. Magic (1) Opcode (1) Key Length (2) Extras Length (1)

    Data Type (1) Status (2) Total Body Length (4) Opaque (4) CAS (8) Memcached Binary Header (24 Bytes)
  26. None
  27. It’s fast.

  28. 1 JVM, 1 CB Node, localhost

  29. https://github.com/Netflix-Skunkworks/WSPerfLab/blob/master/test-results/RxNetty_vs_Tomcat_April2015.pdf

  30. https://github.com/Netflix-Skunkworks/WSPerfLab/blob/master/test-results/RxNetty_vs_Tomcat_April2015.pdf

  31. Techempower, Round 12 https://www.techempower.com/benchmarks/#section=data-r12&hw=peak&test=plaintext&l=27wqyn

  32. Techempower, Round 12 https://www.techempower.com/benchmarks/#section=data-r12&hw=peak&test=plaintext&l=27wqyn

  33. Why? Efficient EventLoop/Socket Multiplexing GC Optimized Less Allocations Pooling Statics

    & Reuse Selected use of sun.misc.Unsafe Lots of “Mechanical Sympathy”
  34. Why? Efficient EventLoop/Socket Multiplexing GC Optimized Less Allocations Pooling Statics

    & Reuse Selected use of sun.misc.Unsafe Lots of “Mechanical Sympathy”
  35. Why? Efficient EventLoop/Socket Multiplexing GC Optimized Less Allocations Pooling Statics

    & Reuse Selected use of sun.misc.Unsafe Lots of “Mechanical Sympathy”
  36. Wait! There is more.

  37. None
  38. None
  39. http://i3.kym-cdn.com/photos/images/original/000/006/933/Massimo.jpg

  40. NioEventLoopGroup → EpollEventLoopGroup NioEventLoop → EpollEventLoop NioServerSocketChannel → EpollServerSocketChannel NioSocketChannel

    → EpollSocketChannel
  41. None
  42. https://blog.twitter.com/2013/netty-4-at-twitter-reduced-gc-overhead

  43. Where Next?

  44. Make Norman Rich! https://www.manning.com/books/netty-in-action

  45. Start Here Web netty.io IRC #netty on Freenode Mailing List

    groups.google.com/forum/#!forum/netty StackOverflow “netty” tag Bugs github.com/netty/netty/issues
  46. Thanks! Michael Nitschinger, Couchbase, Inc. twitter: @daschl