Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Michael Nitschinger on State of the art JVM networking with Netty

Michael Nitschinger on State of the art JVM networking with Netty

More Decks by Enterprise Java User Group Austria

Other Decks in Technology

Transcript

  1. 1  
    State  Of  The  Art  JVM  Networking  
    with  Ne6y  
    Michael  Nitschinger,  SDK  Engineer  

    View full-size slide

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

    View full-size slide

  3. 3  
    PragmaAsm  
    Enthusiasm  
    Encouragement  
    Simplicity  

    View full-size slide

  4. 4  
    PragmaAsm  
    Enthusiasm  
    Encouragement  
    Simplicity  

    View full-size slide

  5. 5  
    CommunicaAon  

    View full-size slide

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

    View full-size slide

  7. 9  
    Pipelines  

    View full-size slide

  8. 10  
    Encoder  
    Encoder  
    Ne4y  
    Writes  
    Ne4y  
    Reads  
    Decoder  
    Decoder  

    View full-size slide

  9. 11  
    Encoder  
    Encoder  
    Ne4y  
    Writes  
    Ne4y  
    Reads  
    Decoder  
    Decoder  

    View full-size slide

  10. 12  
    Encoder  
    Encoder  
    Ne4y  
    Writes  
    Ne4y  
    Reads  
    Decoder  
    Decoder  

    View full-size slide

  11. 13  
    Encoder  
    Encoder  
    Ne4y  
    Writes  
    Ne4y  
    Reads  
    Decoder  
    Decoder  

    View full-size slide

  12. 14  
    Encoder  
    Encoder  
    Ne4y  
    Writes  
    Ne4y  
    Reads  
    Decoder  
    Decoder  

    View full-size slide

  13. 15  
    Encoder  
    Encoder  
    Ne4y  
    Writes  
    Ne4y  
    Reads  
    Decoder  
    Decoder  

    View full-size slide

  14. 16  
    Encoder  
    Encoder  
    Ne4y  
    Writes  
    Ne4y  
    Reads  
    Decoder  
    Decoder  

    View full-size slide

  15. 17  
    Outbound  
    Handler  
    Outbound  
    Handler  
    Ne4y  
    Writes  
    Ne4y  
    Reads  
    Inbound  
    Handler  
    Inbound  
    Handler  

    View full-size slide

  16. 19  
    ChannelHandlers  

    View full-size slide

  17. 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  NoPficaPons  

    View full-size slide

  18. 21  
    Handler  Hierachy  
    ChannelHandler  
    ChannelInboundHandler  
    ChannelInboundHandlerAdapter  
    ChannelOutboundHandler  
    ChannelOutboundHandlerAdapter  

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  21. 27  
    Provided  Codecs  
    •  HTTP  
    •  HTTP2  
    •  Websockets  
    •  SPDY  
    •  Memcache  
    •  SerializaAon  
    •  Socks  
    •  JBoss  Marshaling  
    •  Protobuf  
    •  SSL  
    •  Zlib  

    View full-size slide

  22. 28  
    Provided  Codecs  
    •  HTTP  
    •  HTTP2  
    •  Websockets  
    •  SPDY  
    •  Memcache  
    •  SerializaAon  
    •  Socks  
    •  JBoss  Marshaling  
    •  Protobuf  
    •  SSL  
    •  Zlib  

    View full-size slide

  23. 29  
    Bootstrap  

    View full-size slide

  24. 30  
    PragmaAsm  
    Enthusiasm  
    Encouragement  
    Simplicity  

    View full-size slide

  25. 31  
    Performance  

    View full-size slide

  26. 32  
    Couchbase  &  Ne6y  

    View full-size slide

  27. 33  
    Techempower  Round  9  
    Plaintext  i7  

    View full-size slide

  28. 34  
    Why?  
    •  Efficient  EventLoop/Socket  MulAplexing  
    •  GC  opAmized  
    ­  Less  allocaPons  
    ­  Caching/Pooling  
    ­  StaPc  Instances  
    ­  Selected  use  of  sun.misc.Unsafe  
    •  Lots  of  „Mechanical  Sympathy“  

    View full-size slide

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

    View full-size slide

  30. 36  
    The  extra  mile  

    View full-size slide

  31. 38  
    NaAve  Epoll  Transport  
    •  JNI  based  wrapper  around  Linux  Epoll  for  TCP  and  UDP  
    •  GC  opAmized  
    •  Support  for:  TCP_CORK  and  SO_REUSEADDR  
    ­  TCP_CORK:  Helps  with  data  batching  
    ­  SO_REUSEADDR:  UDP  MulPcast  

    View full-size slide

  32. 39  
    NaAve  Bootstrap  

    View full-size slide

  33. 40  
    PrimiAve  CollecAons  

    View full-size slide

  34. 41  
    ByteBuf  Pooling  
    h6ps://blog.twi6er.com/2013/ne6y-­‐4-­‐at-­‐twi6er-­‐reduced-­‐gc-­‐overhead  

    View full-size slide

  35. 42  
    PragmaAsm  
    Enthusiasm  
    Encouragement  
    Simplicity  

    View full-size slide

  36. 43  
    Reusability  

    View full-size slide

  37. 44  
    Regular  Releases  

    View full-size slide

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

    View full-size slide

  39. 46  
    PragmaAsm  
    Enthusiasm  
    Encouragement  
    Simplicity  

    View full-size slide

  40. 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  PozoloPn,  Frederic  Bregier,  Shawn  Silverman,  
    Evan  Meagher,  iainmcgin,  Prajwal  Tuladhar,  Derek  Troy-­‐West,  ursa,  
    dantran,  alexey,  kerr,  Aaron  Riekenberg,  Andrei.PozoloPn,  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  

    View full-size slide

  41. 50  
    Vladimir  Schafer,  alain,  fredericBregier,  izstas,  radimch,  Greg  SolPs,  
    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,  ValenPn  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,  JaPnder,  Andrew  
    Gaul,  James  Roper,  marius  a.  eriksen,  Ionuț  G.  Stan,  Johan  Rask,  Ian  
    Barfield,  Josh  Wilson,  JusPn  Santa  Barbara,  milenkovicm,  Ma4hias  
    Wessendorf,.....  ...you?  

    View full-size slide

  42. 51  
    Geing  Help  
    •  Start  here:  ne6y.io  
    •  IRC:  #ne6y  on  Freenode  
    •  Mailing  List:    
    h6ps://groups.google.com/forum/#!forum/ne6y  
    •  Stackoverflow:  „ne6y“  tag  
    •  Bugtracker:  h6ps://github.com/ne6y/ne6y/issues  
     

    View full-size slide

  43. 52  
    Ne6y  in  AcAon  
    by  Norman  Maurer  
    manning.com/maurer  
     

    View full-size slide

  44. 53  
    ContribuAng  
    1.  Read:  h6p://ne6y.io/wiki/developer-­‐guide.html  
    2.  Fork:  h6ps://github.com/ne6y/ne6y  
    3.  Submit  PR:  h6ps://github.com/ne6y/ne6y/pulls  
    4.  Be  prepared  for  some  feedback/improvement  cycles!  
    5.  Get  menAoned  in  the  release  notes  

    View full-size slide

  45. 54  
    QuesAons?  

    View full-size slide