Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

It’s simple.

Slide 6

Slide 6 text

Half-Duplex Full-Duplex

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

ChannelHandler ChannelHandler ChannelHandler ChannelHandler Pipeline

Slide 9

Slide 9 text

Encoder Encoder Decoder Decoder

Slide 10

Slide 10 text

OutboundHandler OutboundHandler InboundHandler InboundHandler

Slide 11

Slide 11 text

Encoder Encoder Decoder Decoder Codec Codec

Slide 12

Slide 12 text

BinaryMemcacheObjectAggregator KeyValueAuthHandler KeyValueFeatureHandler BinaryMemcacheClientCodec KeyValueHandler

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

“Each Handler receives events from the pipeline and emits events into the pipeline.“

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

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

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

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)

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

It’s fast.

Slide 28

Slide 28 text

1 JVM, 1 CB Node, localhost

Slide 29

Slide 29 text

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

Slide 30

Slide 30 text

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

Slide 31

Slide 31 text

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

Slide 32

Slide 32 text

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

Slide 33

Slide 33 text

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

Slide 34

Slide 34 text

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

Slide 35

Slide 35 text

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

Slide 36

Slide 36 text

Wait! There is more.

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

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

Slide 40

Slide 40 text

NioEventLoopGroup → EpollEventLoopGroup NioEventLoop → EpollEventLoop NioServerSocketChannel → EpollServerSocketChannel NioSocketChannel → EpollSocketChannel

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

https://blog.twitter.com/2013/netty-4-at-twitter-reduced-gc-overhead

Slide 43

Slide 43 text

Where Next?

Slide 44

Slide 44 text

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

Slide 45

Slide 45 text

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

Slide 46

Slide 46 text

Thanks! Michael Nitschinger, Couchbase, Inc. twitter: @daschl