Slide 1

Slide 1 text

Michael  Nitschinger  (@daschl)    JVM  Engineer  @  Couchbase,  Inc.   State  of  the  Art  JVM   Networking  with  Ne;y  4   The Walking Dead A Survival Guide to Resilient Reactive Applications Michael Nitschinger @daschl Netty State of the Art JVM Networking Michael Nitschinger @daschl

Slide 2

Slide 2 text

2       “Ne#y  is  an  asynchronous  and  event-­‐driven   network  applica0on  framework  for  rapid   development  of  maintainable  high  performance   protocol  servers  &  clients.“  

Slide 3

Slide 3 text

3   Pragma@sm   Enthusiasm   Encouragement   Simplicity  

Slide 4

Slide 4 text

4   Pragma@sm   Enthusiasm   Encouragement   Simplicity  

Slide 5

Slide 5 text

5   Communica@on  

Slide 6

Slide 6 text

6   Half-­‐Duplex       (HTTP)   Full-­‐Duplex   (Websockets)  

Slide 7

Slide 7 text

7  

Slide 8

Slide 8 text

8  

Slide 9

Slide 9 text

9   Pipelines  

Slide 10

Slide 10 text

10   Encoder   Encoder   NeCy   Writes   NeCy   Reads   Decoder   Decoder  

Slide 11

Slide 11 text

11   Encoder   Encoder   NeCy   Writes   NeCy   Reads   Decoder   Decoder  

Slide 12

Slide 12 text

12   Encoder   Encoder   NeCy   Writes   NeCy   Reads   Decoder   Decoder  

Slide 13

Slide 13 text

13   Encoder   Encoder   NeCy   Writes   NeCy   Reads   Decoder   Decoder  

Slide 14

Slide 14 text

14   Encoder   Encoder   NeCy   Writes   NeCy   Reads   Decoder   Decoder  

Slide 15

Slide 15 text

15   Encoder   Encoder   NeCy   Writes   NeCy   Reads   Decoder   Decoder  

Slide 16

Slide 16 text

16   Encoder   Encoder   NeCy   Writes   NeCy   Reads   Decoder   Decoder  

Slide 17

Slide 17 text

17   Outbound   Handler   Outbound   Handler   NeCy   Writes   NeCy   Reads   Inbound   Handler   Inbound   Handler  

Slide 18

Slide 18 text

18  

Slide 19

Slide 19 text

19   ChannelHandlers  

Slide 20

Slide 20 text

20   Handlers  are  your  Workers   Each  handler  receives  messages  and  poten;ally  emits   messages.   •  Use  them  for   ­  Encoding  &  Decoding  („Codec“)   ­  Business-­‐Logic   ­  State  Changes   ­  Event  NoVficaVons  

Slide 21

Slide 21 text

21   Handler  Hierachy   ChannelHandler   ChannelInboundHandler   ChannelInboundHandlerAdapter   ChannelOutboundHandler   ChannelOutboundHandlerAdapter  

Slide 22

Slide 22 text

22  

Slide 23

Slide 23 text

23  

Slide 24

Slide 24 text

24  

Slide 25

Slide 25 text

25   Handler  Types   •  Encoder   ­  MessageToByte   ­  MessageToMessage   •  Decoder   ­  ByteToMessage   ­  MessageToMessage   •  Hybrid  Codecs   ­  ByteToByte   ­  ByteToMessage   ­  MessageToMessage   •  Useful  Decoders   ­  Replay   ­  FixedLengthFrame   ­  LengthFieldBasedFrame   ­  LineBasedFrame   ­  DelimiterBasedFrame  

Slide 26

Slide 26 text

26   Handler  Types   •  Encoder   ­  MessageToByte   ­  MessageToMessage   •  Decoder   ­  ByteToMessage   ­  MessageToMessage   •  Hybrid  Codecs   ­  ByteToByte   ­  ByteToMessage   ­  MessageToMessage   •  Useful  Decoders   ­  Replay   ­  FixedLengthFrame   ­  LengthFieldBasedFrame   ­  LineBasedFrame   ­  DelimiterBasedFrame  

Slide 27

Slide 27 text

27   Provided  Codecs   •  HTTP   •  HTTP2   •  Websockets   •  SPDY   •  Memcache   •  Serializa@on   •  Socks   •  JBoss  Marshaling   •  Protobuf   •  SSL   •  Zlib  

Slide 28

Slide 28 text

28   Provided  Codecs   •  HTTP   •  HTTP2   •  Websockets   •  SPDY   •  Memcache   •  Serializa@on   •  Socks   •  JBoss  Marshaling   •  Protobuf   •  SSL   •  Zlib  

Slide 29

Slide 29 text

29   Bootstrap  

Slide 30

Slide 30 text

30   Pragma@sm   Enthusiasm   Encouragement   Simplicity  

Slide 31

Slide 31 text

31   Performance  

Slide 32

Slide 32 text

32   Couchbase  &  Ne;y  

Slide 33

Slide 33 text

33   Techempower  Round  9   Plaintext  i7  

Slide 34

Slide 34 text

34   Why?   •  Efficient  EventLoop/Socket  Mul@plexing   •  GC  op@mized   ­  Less  allocaVons   ­  Caching/Pooling   ­  StaVc  Instances   ­  Selected  use  of  sun.misc.Unsafe   •  Lots  of  „Mechanical  Sympathy“  

Slide 35

Slide 35 text

35   ByteBufs   •  java.nio.ByteBuffer  replacement   ­  Simpler  API   ­  Feature  rich   ­  Embraces  reusability   ­  CompositeByteBuf   Reader     Index   Writer   Index   Capacity  

Slide 36

Slide 36 text

36   The  extra  mile  

Slide 37

Slide 37 text

37  

Slide 38

Slide 38 text

38   Na@ve  Epoll  Transport   •  JNI  based  wrapper  around  Linux  Epoll  for  TCP  and  UDP   •  GC  op@mized   •  Support  for:  TCP_CORK  and  SO_REUSEADDR   ­  TCP_CORK:  Helps  with  data  batching   ­  SO_REUSEADDR:  UDP  MulVcast  

Slide 39

Slide 39 text

39   Na@ve  Bootstrap  

Slide 40

Slide 40 text

40   Primi@ve  Collec@ons  

Slide 41

Slide 41 text

41   ByteBuf  Pooling   h;ps://blog.twi;er.com/2013/ne;y-­‐4-­‐at-­‐twi;er-­‐reduced-­‐gc-­‐overhead  

Slide 42

Slide 42 text

42   Pragma@sm   Enthusiasm   Encouragement   Simplicity  

Slide 43

Slide 43 text

43   Reusability  

Slide 44

Slide 44 text

44   Regular  Releases  

Slide 45

Slide 45 text

45   •  Based  on:   ­  Akka‘s  AbstractNodeQueue   ­  hCp://www.1024cores.net/home/lock-­‐free-­‐algorithms/queues/non-­‐ intrusive-­‐mpsc-­‐node-­‐based-­‐queue    

Slide 46

Slide 46 text

46   Pragma@sm   Enthusiasm   Encouragement   Simplicity  

Slide 47

Slide 47 text

47  

Slide 48

Slide 48 text

48  

Slide 49

Slide 49 text

49   Jestan  Nirojan,  Cruz  Julian  Bishop,  Frédéric  Brégier,  Jeff  Pinner,   Veebs,  Michael  Nitschinger,  vibul,  Craig  P.  Motlin,  Daniel  Bevenius,   Vibul  Imtarnasan,  Luke  Wood,  Cruz  Bishop,  Bill  Gallagher,  ab,   alepar,  bgallagher,  Andy  Taylor,  Ngoc  Dao,  John  Fallows,  Jakob   Buchgraber,  Andrei  PozoloVn,  Frederic  Bregier,  Shawn  Silverman,   Evan  Meagher,  iainmcgin,  Prajwal  Tuladhar,  Derek  Troy-­‐West,  ursa,   dantran,  alexey,  kerr,  Aaron  Riekenberg,  Andrei.PozoloVn,  kxbmap,   Courtney  Robinson,  Sun  Ning,  zhen9ao,  Alex  Petrov,  Bruce   Mitchener,  Chris  Mowforth,  Edwin  Mol,  Evans  Yang,  Guido  García,   James  Abley,  Jeff  Griffith,  Jeff  Smick,  Leonardo  Freitas  Gomes,  Mike   Heath,  Mike  Schore,  Mirko  Caserta,  Roman  Stoffel  

Slide 50

Slide 50 text

50   Vladimir  Schafer,  alain,  fredericBregier,  izstas,  radimch,  Greg  SolVs,   Michael  Grove,  George  Cao,  MiddleBen,  nibin,  Andrew  Cox,   pfisterer,  Felix  Trepanier,  Eric  Charles,  Olaf  Bergner,  Phillip   Schichtel,  Dennis  Boldt,  Rogie  Sulzbach,  Adam  Vandenberg,  Ryan   Shelley,  Sasha  Zverev,  David  Dossot,  Stephane  Landelle,  Dao  Ngoc,   Sunng,  Tony  Rice,  CoNDoRip,  ValenVn  Kovalenko,  Carl  Byström,   Brian  Roach,  Vladimir  Krivosheev,  shreyharia,  Will,  William  Kemper,   Wolfgang  Profer,  Brendt  Lucas,  tsingxu,  Bourne,  Geoff,  Benoit   Sigoure,  Atsuhiko  Yamanaka,  bk1te,  cmcmaugh,  coltnz,  AtKaaZ,   Andrej  Golovnin,  hepin1989,  Artur  Dryomov,  irelandKen,  Alexey   Diomin,  jwilson,  Arron  Norwell,  Jamie  Furness,  JaVnder,  Andrew   Gaul,  James  Roper,  marius  a.  eriksen,  Ionuț  G.  Stan,  Johan  Rask,  Ian   Barfield,  Josh  Wilson,  JusVn  Santa  Barbara,  milenkovicm,  MaChias   Wessendorf,.....  ...you?  

Slide 51

Slide 51 text

51   Geing  Help   •  Start  here:  ne;y.io   •  IRC:  #ne;y  on  Freenode   •  Mailing  List:     h;ps://groups.google.com/forum/#!forum/ne;y   •  Stackoverflow:  „ne;y“  tag   •  Bugtracker:  h;ps://github.com/ne;y/ne;y/issues    

Slide 52

Slide 52 text

52   Ne;y  in  Ac@on   by  Norman  Maurer   manning.com/maurer    

Slide 53

Slide 53 text

53   Contribu@ng   1.  Read:  h;p://ne;y.io/wiki/developer-­‐guide.html   2.  Fork:  h;ps://github.com/ne;y/ne;y   3.  Submit  PR:  h;ps://github.com/ne;y/ne;y/pulls   4.  Be  prepared  for  some  feedback/improvement  cycles!   5.  Get  men@oned  in  the  release  notes  

Slide 54

Slide 54 text

54   Ques@ons?