SlideShare a Scribd company logo
Netty
List("Asynchronous", "data", "transfer")
      ::: List("practical", "aspects")




                            Victor Cherkassky
                    "vcherkassky@gmail.com"
What is Netty
         IO library



        IO
cat Files > Networking
What is Netty
                   IO library
                   asynchronous

    ChannelFuture future = channel.write(message)
future.addListener(WRITE_COMPLETE_LISTENER)
What is Netty
                          IO library
                          asynchronous
                          non-blocking
      /**
        * This method blocks until input data is available
        */
           InputStream.read()
What is Netty
         IO library
         asynchronous
         non-blocking
         multi-protocol

HTTP | WebSocket | Protobuf
         | Binary
     TCP | UDP
blocking vs non-blocking
              blocking (OIO)
Ipttemi =nwFlIpttem"nu.i";
 nuSra s  e ienuSra(iptbn)
itbt =i.ed) / crettra wisfrrsl o err
 n ye  sra(; / urn hed at o eut r ro




            non-blocking (NIO)
wie(re {
 hl tu)
  slco.eet) / rqetn eet fo mlil canl
   eetrslc(; / eusig vns rm utpe hnes
  Ieao i =slco.eetdes)ieao(;
   trtr t  eetrslceKy(.trtr)
  wie(thset) {
   hl i.aNx()
    SlcoKyky=(eetoKy i.et)
    eetre e   Slcine) tnx(;
    hnlKyky;
    adee(e)
    i.eoe)
    trmv(;
  }
}
blocking vs non-blocking
   Hardware blocking write
blocking vs non-blocking
Hardware non-blocking write: DMA
blocking vs non-blocking
                     OS
select()/poll() - traditional POSIX polling O(n)
epoll() - event-based polling O(1), Linux 2.5.44+
kqueue - FreeBSD, Mac OS X
I/O Completion Ports - Windows NT 3.5+, Solaris 10+
blocking vs non-blocking
                        Java
SelectableChannel.register(selector) - blocking operation,
registers an "interest" for IO events
Selector.select - non-blocking operation, checks for
occurred events
blocking vs non-blocking

            Java                            OS
                                     select() / poll() / kqueue
Channel.register & Selector.select   I/O Completion Ports
                                     epoll() - Java 1.6+
Thread model

    Tomcat
 1 request = 1 thread
fast for ~1000 clients
  too much memory
Thread model

    Node.js
all requests = 1 thread
     super scalable
limited error handling
Thread model

       Netty
many requests = 1 thread
    flexible model
Netty web Server
Netty web Client
Channel Pipeline
All terms together
Channel (socket read/write)
channel Buffer (byte array)
channel Event (message)
channel Pipeline (message bus)
channel Handler (message handler)
  Upstream Event (from socket)
  Downstream Event (to socket)
Creating an HTTP server
        Set up thread pools
   boss pool for handling incoming connections
   worker pool for processing IO

piaefnlEeuo bsPo =Eeuosnwahdhedol)
 rvt ia xctr osol  xctr.eCceTraPo(
;
piaefnlEeuo wrePo =Eeuosnwahdhedol
 rvt ia xctr okrol  xctr.eCceTraPo
(;
 )
Creating an HTTP server
    Provide ChannelFactory
piaefnlCanlatr canlatr =
 rvt ia hneFcoy hneFcoy
   nwNoevrokthneFcoybsPo,wrePo)
   e iSreSceCanlatr(osol okrol;
Creating an HTTP server
         Set up PipelineFactory
piaefnlCanlieieatr pplnFcoy=
 rvt ia hnePplnFcoy ieieatr
   nwCanlieieatr( {
   e hnePplnFcoy)
  @vrie
  Oerd
  pbi Canlieiegtieie)trw Ecpin{
  ulc hnePpln ePpln( hos xeto

      Canlieiep=Canl.ieie)
      hnePpln    hnesppln(;
      padat"tpevroe" nwHtSreCdc);
      .dLs(htSreCdc, e tpevroe()

      padat"ade" nwCsoRqetade(lCanl);
      .dLs(hnlr, e utmeusHnlralhnes)

      rtr p
      eun ;
  }
};
Creating an HTTP server
 Put all together with Bootstrap
piaefnlSreBosrpbosrp=nwSreBosrpca
 rvt ia evrotta otta e evrotta(h
neFcoy;
 nlatr)

 ...

bosrpstieieatr(ieieatr)
 otta.ePplnFcoypplnFcoy;

/ Otosfraprn canl-i acpscnetos
 / pin o aet hne   t cet oncin
bosrpstpin"oaAdes,nwIeSceAdespr);
 otta.eOto(lcldrs" e ntoktdrs(ot)
bosrpstpin"esAdes,tu)
 otta.eOto(ruedrs" re;

/ Otosfriscide -te poesI
 / pin o t hlrn hy rcs O
bosrpstpin"hl.cNDly,tu)
 otta.eOto(cidtpoea" re;
bosrpstpin"hl.eplv" fle;
 otta.eOto(cidkeAie, as)
Creating an HTTP server
    Writing a custom handler
casCsoHnlretnsSmlCanlptemade {
 ls utmade xed ipehneUsraHnlr
   ...
  @vrie
   Oerd
  pbi vi msaeeevdCanladeCnetcx Msae
   ulc od esgRcie(hneHnlrotx t, esgE
vn e trw Ecpin{
 et ) hos xeto
    HtRqetrq=(tpeus)egtesg(;
     tpeus e   HtRqet .eMsae)
    / pouersos adwiei t acanl
     / rdc epne n rt t o hne
    HtRsos rs=nwDfuttpepneHT__,O)
     tpepne e   e ealHtRsos(TP11 K;
    Canluueftr =Canl.rt(t.eCanl) rs;
     hneFtr uue   hneswiecxgthne(, e)
    ftr.dLsee(hneFtrLsee.LS)
     uueaditnrCanluueitnrCOE;
  }
}
Creating an HTTP server
Gather channels for future closing
piaefnlCanlru alhnes=nwDfuthneGop
 rvt ia hneGop lCanl    e ealCanlru(
)
    ...
/ aanisd orcso hnlr
 / gi nie u utm ade
casCsoHnlretnsSmlCanlptemade {
 ls utmade xed ipehneUsraHnlr
    ...
    @vrie
    Oerd
  pbi vi canlpnCanladeCnetcx Canltt
   ulc od hneOe(hneHnlrotx t, hneSae
Eete trw Ecpin{
 vn ) hos xeto
    Canlcanl=egthne(;
    hne hne   .eCanl)
    alhnesadcanl;
    lCanl.d(hne)
  }
}
Creating an HTTP server
        Release resources
         close gathered channels
         release external resources

alhnescoe)aatnnerpil(;
 lCanl.ls(.wiUitrutby)
bosrprlaexenleore(;
 otta.eesEtraRsucs)
TCPnodelay, TCPkeepalive
  Remember that bootstrap code?

 / Otosfriscide -te poesI
  / pin o t hlrn hy rcs O
 bosrpstpin"hl.cNDly,tu)
  otta.eOto(cidtpoea" re;
 bosrpstpin"hl.eplv" fle;
  otta.eOto(cidkeAie, as)




   What do these options mean?
TCP keepAlive

prolongs each TCP connection
makes NAT router happy
TCP noDelay
   Nagle's algorithm

glues up small TCP packets
tries to reduce bandwidth
increases latency
TCPnodelay, TCPkeepalive

    To use,
 or not to use?
Don't ask,
measure!
Thank you
Additional resources
    netty @ github
    introductory article

More Related Content

What's hot

Connecting to the network
Connecting to the networkConnecting to the network
Connecting to the networkMu Chun Wang
 
Building scalable network applications with Netty (as presented on NLJUG JFal...
Building scalable network applications with Netty (as presented on NLJUG JFal...Building scalable network applications with Netty (as presented on NLJUG JFal...
Building scalable network applications with Netty (as presented on NLJUG JFal...
Jaap ter Woerds
 
Developing High Performance Application with Aerospike & Go
Developing High Performance Application with Aerospike & GoDeveloping High Performance Application with Aerospike & Go
Developing High Performance Application with Aerospike & Go
Chris Stivers
 
无锁编程
无锁编程无锁编程
无锁编程
vorfeed chen
 
Socket.io v.0.8.3
Socket.io v.0.8.3Socket.io v.0.8.3
Socket.io v.0.8.3
Maryna Vasina
 
Taking advantage of Prometheus relabeling
Taking advantage of Prometheus relabelingTaking advantage of Prometheus relabeling
Taking advantage of Prometheus relabeling
Julien Pivotto
 
Python twisted
Python twistedPython twisted
Python twisted
Mahendra M
 
Briefly Rust - Daniele Esposti - Codemotion Rome 2017
Briefly Rust - Daniele Esposti - Codemotion Rome 2017Briefly Rust - Daniele Esposti - Codemotion Rome 2017
Briefly Rust - Daniele Esposti - Codemotion Rome 2017
Codemotion
 
Pemrograman Jaringan
Pemrograman JaringanPemrograman Jaringan
Pemrograman Jaringan
belajarkomputer
 
Counter Wars (JEEConf 2016)
Counter Wars (JEEConf 2016)Counter Wars (JEEConf 2016)
Counter Wars (JEEConf 2016)
Alexey Fyodorov
 
How to Leverage Go for Your Networking Needs
How to Leverage Go for Your Networking NeedsHow to Leverage Go for Your Networking Needs
How to Leverage Go for Your Networking Needs
DigitalOcean
 
Streams are Awesome - (Node.js) TimesOpen Sep 2012
Streams are Awesome - (Node.js) TimesOpen Sep 2012 Streams are Awesome - (Node.js) TimesOpen Sep 2012
Streams are Awesome - (Node.js) TimesOpen Sep 2012 Tom Croucher
 
Twisted logic
Twisted logicTwisted logic
Twisted logicashfall
 
Async await in C++
Async await in C++Async await in C++
Async await in C++
cppfrug
 
Iss letcure 7_8
Iss letcure 7_8Iss letcure 7_8
Iss letcure 7_8Ali Habeeb
 
C#을 이용한 task 병렬화와 비동기 패턴
C#을 이용한 task 병렬화와 비동기 패턴C#을 이용한 task 병렬화와 비동기 패턴
C#을 이용한 task 병렬화와 비동기 패턴
명신 김
 
Nessus scan report using microsoft patchs scan policy - Tareq Hanaysha
Nessus scan report using microsoft patchs scan policy - Tareq HanayshaNessus scan report using microsoft patchs scan policy - Tareq Hanaysha
Nessus scan report using microsoft patchs scan policy - Tareq Hanaysha
Hanaysha
 
The future of async i/o in Python
The future of async i/o in PythonThe future of async i/o in Python
The future of async i/o in Python
Saúl Ibarra Corretgé
 
Chatting dengan beberapa pc laptop
Chatting dengan beberapa pc laptopChatting dengan beberapa pc laptop
Chatting dengan beberapa pc laptopyayaria
 
Improving rpc bkp
Improving rpc bkpImproving rpc bkp
Improving rpc bkp
eleksdev
 

What's hot (20)

Connecting to the network
Connecting to the networkConnecting to the network
Connecting to the network
 
Building scalable network applications with Netty (as presented on NLJUG JFal...
Building scalable network applications with Netty (as presented on NLJUG JFal...Building scalable network applications with Netty (as presented on NLJUG JFal...
Building scalable network applications with Netty (as presented on NLJUG JFal...
 
Developing High Performance Application with Aerospike & Go
Developing High Performance Application with Aerospike & GoDeveloping High Performance Application with Aerospike & Go
Developing High Performance Application with Aerospike & Go
 
无锁编程
无锁编程无锁编程
无锁编程
 
Socket.io v.0.8.3
Socket.io v.0.8.3Socket.io v.0.8.3
Socket.io v.0.8.3
 
Taking advantage of Prometheus relabeling
Taking advantage of Prometheus relabelingTaking advantage of Prometheus relabeling
Taking advantage of Prometheus relabeling
 
Python twisted
Python twistedPython twisted
Python twisted
 
Briefly Rust - Daniele Esposti - Codemotion Rome 2017
Briefly Rust - Daniele Esposti - Codemotion Rome 2017Briefly Rust - Daniele Esposti - Codemotion Rome 2017
Briefly Rust - Daniele Esposti - Codemotion Rome 2017
 
Pemrograman Jaringan
Pemrograman JaringanPemrograman Jaringan
Pemrograman Jaringan
 
Counter Wars (JEEConf 2016)
Counter Wars (JEEConf 2016)Counter Wars (JEEConf 2016)
Counter Wars (JEEConf 2016)
 
How to Leverage Go for Your Networking Needs
How to Leverage Go for Your Networking NeedsHow to Leverage Go for Your Networking Needs
How to Leverage Go for Your Networking Needs
 
Streams are Awesome - (Node.js) TimesOpen Sep 2012
Streams are Awesome - (Node.js) TimesOpen Sep 2012 Streams are Awesome - (Node.js) TimesOpen Sep 2012
Streams are Awesome - (Node.js) TimesOpen Sep 2012
 
Twisted logic
Twisted logicTwisted logic
Twisted logic
 
Async await in C++
Async await in C++Async await in C++
Async await in C++
 
Iss letcure 7_8
Iss letcure 7_8Iss letcure 7_8
Iss letcure 7_8
 
C#을 이용한 task 병렬화와 비동기 패턴
C#을 이용한 task 병렬화와 비동기 패턴C#을 이용한 task 병렬화와 비동기 패턴
C#을 이용한 task 병렬화와 비동기 패턴
 
Nessus scan report using microsoft patchs scan policy - Tareq Hanaysha
Nessus scan report using microsoft patchs scan policy - Tareq HanayshaNessus scan report using microsoft patchs scan policy - Tareq Hanaysha
Nessus scan report using microsoft patchs scan policy - Tareq Hanaysha
 
The future of async i/o in Python
The future of async i/o in PythonThe future of async i/o in Python
The future of async i/o in Python
 
Chatting dengan beberapa pc laptop
Chatting dengan beberapa pc laptopChatting dengan beberapa pc laptop
Chatting dengan beberapa pc laptop
 
Improving rpc bkp
Improving rpc bkpImproving rpc bkp
Improving rpc bkp
 

Viewers also liked

Netty Notes Part 3 - Channel Pipeline and EventLoops
Netty Notes Part 3 - Channel Pipeline and EventLoopsNetty Notes Part 3 - Channel Pipeline and EventLoops
Netty Notes Part 3 - Channel Pipeline and EventLoops
Rick Hightower
 
Netty - a pragmatic introduction
Netty - a pragmatic introductionNetty - a pragmatic introduction
Netty - a pragmatic introduction
Raphael Stary
 
Zero-Copy Event-Driven Servers with Netty
Zero-Copy Event-Driven Servers with NettyZero-Copy Event-Driven Servers with Netty
Zero-Copy Event-Driven Servers with NettyDaniel Bimschas
 
Introduction of netty
Introduction of nettyIntroduction of netty
Introduction of nettyBing Luo
 
Notes on Netty baics
Notes on Netty baicsNotes on Netty baics
Notes on Netty baics
Rick Hightower
 
Real time analytics with Netty, Storm, Kafka
Real time analytics with Netty, Storm, KafkaReal time analytics with Netty, Storm, Kafka
Real time analytics with Netty, Storm, KafkaTrieu Nguyen
 
Netty from the trenches
Netty from the trenchesNetty from the trenches
Netty from the trenches
Jordi Gerona
 
深入浅出Netty l.t
深入浅出Netty   l.t深入浅出Netty   l.t
深入浅出Netty l.toleone
 
Netty
NettyNetty
Asynchronous, Event-driven Network Application Development with Netty
Asynchronous, Event-driven Network Application Development with NettyAsynchronous, Event-driven Network Application Development with Netty
Asynchronous, Event-driven Network Application Development with Netty
Ersin Er
 
Nettyらへん
NettyらへんNettyらへん
NettyらへんGo Tanaka
 
Netty 4-based RPC System Development
Netty 4-based RPC System DevelopmentNetty 4-based RPC System Development
Netty 4-based RPC System DevelopmentAllan Huang
 
Building Netty Servers
Building Netty ServersBuilding Netty Servers
Building Netty Servers
Dani Solà Lagares
 
Xitrum internals
Xitrum internalsXitrum internals
Xitrum internalsNgoc Dao
 
Everything you wanted to know about writing async, concurrent http apps in java
Everything you wanted to know about writing async, concurrent http apps in java Everything you wanted to know about writing async, concurrent http apps in java
Everything you wanted to know about writing async, concurrent http apps in java
Baruch Sadogursky
 
Netty
NettyNetty
Netty
Jaejin Yun
 
Formal Grammars
Formal GrammarsFormal Grammars
Formal Grammars
Eelco Visser
 
Asynchronous serial data transfer, UART and CAN controller
Asynchronous serial data transfer, UART and CAN controllerAsynchronous serial data transfer, UART and CAN controller
Asynchronous serial data transfer, UART and CAN controller
Jovan Vlajic
 
High performance network programming on the jvm oscon 2012
High performance network programming on the jvm   oscon 2012 High performance network programming on the jvm   oscon 2012
High performance network programming on the jvm oscon 2012
Erik Onnen
 
Scalability using Node.js
Scalability using Node.jsScalability using Node.js
Scalability using Node.js
ratankadam
 

Viewers also liked (20)

Netty Notes Part 3 - Channel Pipeline and EventLoops
Netty Notes Part 3 - Channel Pipeline and EventLoopsNetty Notes Part 3 - Channel Pipeline and EventLoops
Netty Notes Part 3 - Channel Pipeline and EventLoops
 
Netty - a pragmatic introduction
Netty - a pragmatic introductionNetty - a pragmatic introduction
Netty - a pragmatic introduction
 
Zero-Copy Event-Driven Servers with Netty
Zero-Copy Event-Driven Servers with NettyZero-Copy Event-Driven Servers with Netty
Zero-Copy Event-Driven Servers with Netty
 
Introduction of netty
Introduction of nettyIntroduction of netty
Introduction of netty
 
Notes on Netty baics
Notes on Netty baicsNotes on Netty baics
Notes on Netty baics
 
Real time analytics with Netty, Storm, Kafka
Real time analytics with Netty, Storm, KafkaReal time analytics with Netty, Storm, Kafka
Real time analytics with Netty, Storm, Kafka
 
Netty from the trenches
Netty from the trenchesNetty from the trenches
Netty from the trenches
 
深入浅出Netty l.t
深入浅出Netty   l.t深入浅出Netty   l.t
深入浅出Netty l.t
 
Netty
NettyNetty
Netty
 
Asynchronous, Event-driven Network Application Development with Netty
Asynchronous, Event-driven Network Application Development with NettyAsynchronous, Event-driven Network Application Development with Netty
Asynchronous, Event-driven Network Application Development with Netty
 
Nettyらへん
NettyらへんNettyらへん
Nettyらへん
 
Netty 4-based RPC System Development
Netty 4-based RPC System DevelopmentNetty 4-based RPC System Development
Netty 4-based RPC System Development
 
Building Netty Servers
Building Netty ServersBuilding Netty Servers
Building Netty Servers
 
Xitrum internals
Xitrum internalsXitrum internals
Xitrum internals
 
Everything you wanted to know about writing async, concurrent http apps in java
Everything you wanted to know about writing async, concurrent http apps in java Everything you wanted to know about writing async, concurrent http apps in java
Everything you wanted to know about writing async, concurrent http apps in java
 
Netty
NettyNetty
Netty
 
Formal Grammars
Formal GrammarsFormal Grammars
Formal Grammars
 
Asynchronous serial data transfer, UART and CAN controller
Asynchronous serial data transfer, UART and CAN controllerAsynchronous serial data transfer, UART and CAN controller
Asynchronous serial data transfer, UART and CAN controller
 
High performance network programming on the jvm oscon 2012
High performance network programming on the jvm   oscon 2012 High performance network programming on the jvm   oscon 2012
High performance network programming on the jvm oscon 2012
 
Scalability using Node.js
Scalability using Node.jsScalability using Node.js
Scalability using Node.js
 

Similar to Netty: asynchronous data transfer

Server side JavaScript: going all the way
Server side JavaScript: going all the wayServer side JavaScript: going all the way
Server side JavaScript: going all the way
Oleg Podsechin
 
Stackless Python In Eve
Stackless Python In EveStackless Python In Eve
Stackless Python In Evel xf
 
Scaling Apache Storm - Strata + Hadoop World 2014
Scaling Apache Storm - Strata + Hadoop World 2014Scaling Apache Storm - Strata + Hadoop World 2014
Scaling Apache Storm - Strata + Hadoop World 2014
P. Taylor Goetz
 
Parallel Processing
Parallel ProcessingParallel Processing
Parallel Processing
RTigger
 
Java7 New Features and Code Examples
Java7 New Features and Code ExamplesJava7 New Features and Code Examples
Java7 New Features and Code Examples
Naresh Chintalcheru
 
Non-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.jsNon-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.js
Marcus Frödin
 
Ngrep commands
Ngrep commandsNgrep commands
Ngrep commands
Rishu Seth
 
Trelles_QnormBOSC2009
Trelles_QnormBOSC2009Trelles_QnormBOSC2009
Trelles_QnormBOSC2009bosc
 
swift-nio のアーキテクチャーと RxHttpClient
swift-nio のアーキテクチャーと RxHttpClientswift-nio のアーキテクチャーと RxHttpClient
swift-nio のアーキテクチャーと RxHttpClient
Shinya Mochida
 
Opendaylight app development
Opendaylight app developmentOpendaylight app development
Opendaylight app development
vjanandr
 
Storm Anatomy
Storm AnatomyStorm Anatomy
Storm Anatomy
Eiichiro Uchiumi
 
ATS Internals
ATS InternalsATS Internals
ATS Internals
Chao Xu
 
ATS Internals
ATS InternalsATS Internals
ATS Internals
Apache Traffic Server
 
Python for Linux System Administration
Python for Linux System AdministrationPython for Linux System Administration
Python for Linux System Administration
vceder
 
The Functional Web
The Functional WebThe Functional Web
The Functional Web
Ryan Riley
 
Introduction to clojure
Introduction to clojureIntroduction to clojure
Introduction to clojure
Abbas Raza
 
Leveraging Hadoop in your PostgreSQL Environment
Leveraging Hadoop in your PostgreSQL EnvironmentLeveraging Hadoop in your PostgreSQL Environment
Leveraging Hadoop in your PostgreSQL Environment
Jim Mlodgenski
 
Reactive Extensions
Reactive ExtensionsReactive Extensions
Reactive Extensions
Dmitri Nesteruk
 

Similar to Netty: asynchronous data transfer (20)

Server side JavaScript: going all the way
Server side JavaScript: going all the wayServer side JavaScript: going all the way
Server side JavaScript: going all the way
 
Stackless Python In Eve
Stackless Python In EveStackless Python In Eve
Stackless Python In Eve
 
Scaling Apache Storm - Strata + Hadoop World 2014
Scaling Apache Storm - Strata + Hadoop World 2014Scaling Apache Storm - Strata + Hadoop World 2014
Scaling Apache Storm - Strata + Hadoop World 2014
 
JS everywhere 2011
JS everywhere 2011JS everywhere 2011
JS everywhere 2011
 
Parallel Processing
Parallel ProcessingParallel Processing
Parallel Processing
 
Java7 New Features and Code Examples
Java7 New Features and Code ExamplesJava7 New Features and Code Examples
Java7 New Features and Code Examples
 
Non-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.jsNon-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.js
 
Ngrep commands
Ngrep commandsNgrep commands
Ngrep commands
 
Trelles_QnormBOSC2009
Trelles_QnormBOSC2009Trelles_QnormBOSC2009
Trelles_QnormBOSC2009
 
swift-nio のアーキテクチャーと RxHttpClient
swift-nio のアーキテクチャーと RxHttpClientswift-nio のアーキテクチャーと RxHttpClient
swift-nio のアーキテクチャーと RxHttpClient
 
Opendaylight app development
Opendaylight app developmentOpendaylight app development
Opendaylight app development
 
Scalaxb preso
Scalaxb presoScalaxb preso
Scalaxb preso
 
Storm Anatomy
Storm AnatomyStorm Anatomy
Storm Anatomy
 
ATS Internals
ATS InternalsATS Internals
ATS Internals
 
ATS Internals
ATS InternalsATS Internals
ATS Internals
 
Python for Linux System Administration
Python for Linux System AdministrationPython for Linux System Administration
Python for Linux System Administration
 
The Functional Web
The Functional WebThe Functional Web
The Functional Web
 
Introduction to clojure
Introduction to clojureIntroduction to clojure
Introduction to clojure
 
Leveraging Hadoop in your PostgreSQL Environment
Leveraging Hadoop in your PostgreSQL EnvironmentLeveraging Hadoop in your PostgreSQL Environment
Leveraging Hadoop in your PostgreSQL Environment
 
Reactive Extensions
Reactive ExtensionsReactive Extensions
Reactive Extensions
 

Recently uploaded

FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
ThomasParaiso2
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 

Recently uploaded (20)

FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 

Netty: asynchronous data transfer

  • 1. Netty List("Asynchronous", "data", "transfer") ::: List("practical", "aspects") Victor Cherkassky "vcherkassky@gmail.com"
  • 2. What is Netty IO library IO cat Files > Networking
  • 3. What is Netty IO library asynchronous ChannelFuture future = channel.write(message) future.addListener(WRITE_COMPLETE_LISTENER)
  • 4. What is Netty IO library asynchronous non-blocking       /**         * This method blocks until input data is available         */ InputStream.read()
  • 5. What is Netty IO library asynchronous non-blocking multi-protocol HTTP | WebSocket | Protobuf | Binary TCP | UDP
  • 6. blocking vs non-blocking blocking (OIO) Ipttemi =nwFlIpttem"nu.i"; nuSra s e ienuSra(iptbn) itbt =i.ed) / crettra wisfrrsl o err n ye sra(; / urn hed at o eut r ro non-blocking (NIO) wie(re { hl tu) slco.eet) / rqetn eet fo mlil canl eetrslc(; / eusig vns rm utpe hnes Ieao i =slco.eetdes)ieao(; trtr t eetrslceKy(.trtr) wie(thset) { hl i.aNx() SlcoKyky=(eetoKy i.et) eetre e Slcine) tnx(; hnlKyky; adee(e) i.eoe) trmv(; } }
  • 7. blocking vs non-blocking Hardware blocking write
  • 8. blocking vs non-blocking Hardware non-blocking write: DMA
  • 9. blocking vs non-blocking OS select()/poll() - traditional POSIX polling O(n) epoll() - event-based polling O(1), Linux 2.5.44+ kqueue - FreeBSD, Mac OS X I/O Completion Ports - Windows NT 3.5+, Solaris 10+
  • 10. blocking vs non-blocking Java SelectableChannel.register(selector) - blocking operation, registers an "interest" for IO events Selector.select - non-blocking operation, checks for occurred events
  • 11. blocking vs non-blocking Java OS select() / poll() / kqueue Channel.register & Selector.select I/O Completion Ports epoll() - Java 1.6+
  • 12. Thread model Tomcat 1 request = 1 thread fast for ~1000 clients too much memory
  • 13. Thread model Node.js all requests = 1 thread super scalable limited error handling
  • 14. Thread model Netty many requests = 1 thread flexible model
  • 18. All terms together Channel (socket read/write) channel Buffer (byte array) channel Event (message) channel Pipeline (message bus) channel Handler (message handler) Upstream Event (from socket) Downstream Event (to socket)
  • 19. Creating an HTTP server Set up thread pools boss pool for handling incoming connections worker pool for processing IO piaefnlEeuo bsPo =Eeuosnwahdhedol) rvt ia xctr osol xctr.eCceTraPo( ; piaefnlEeuo wrePo =Eeuosnwahdhedol rvt ia xctr okrol xctr.eCceTraPo (; )
  • 20. Creating an HTTP server Provide ChannelFactory piaefnlCanlatr canlatr = rvt ia hneFcoy hneFcoy nwNoevrokthneFcoybsPo,wrePo) e iSreSceCanlatr(osol okrol;
  • 21. Creating an HTTP server Set up PipelineFactory piaefnlCanlieieatr pplnFcoy= rvt ia hnePplnFcoy ieieatr nwCanlieieatr( { e hnePplnFcoy) @vrie Oerd pbi Canlieiegtieie)trw Ecpin{ ulc hnePpln ePpln( hos xeto Canlieiep=Canl.ieie) hnePpln hnesppln(; padat"tpevroe" nwHtSreCdc); .dLs(htSreCdc, e tpevroe() padat"ade" nwCsoRqetade(lCanl); .dLs(hnlr, e utmeusHnlralhnes) rtr p eun ; } };
  • 22. Creating an HTTP server Put all together with Bootstrap piaefnlSreBosrpbosrp=nwSreBosrpca rvt ia evrotta otta e evrotta(h neFcoy; nlatr) ... bosrpstieieatr(ieieatr) otta.ePplnFcoypplnFcoy; / Otosfraprn canl-i acpscnetos / pin o aet hne t cet oncin bosrpstpin"oaAdes,nwIeSceAdespr); otta.eOto(lcldrs" e ntoktdrs(ot) bosrpstpin"esAdes,tu) otta.eOto(ruedrs" re; / Otosfriscide -te poesI / pin o t hlrn hy rcs O bosrpstpin"hl.cNDly,tu) otta.eOto(cidtpoea" re; bosrpstpin"hl.eplv" fle; otta.eOto(cidkeAie, as)
  • 23. Creating an HTTP server Writing a custom handler casCsoHnlretnsSmlCanlptemade { ls utmade xed ipehneUsraHnlr ... @vrie Oerd pbi vi msaeeevdCanladeCnetcx Msae ulc od esgRcie(hneHnlrotx t, esgE vn e trw Ecpin{ et ) hos xeto HtRqetrq=(tpeus)egtesg(; tpeus e HtRqet .eMsae) / pouersos adwiei t acanl / rdc epne n rt t o hne HtRsos rs=nwDfuttpepneHT__,O) tpepne e e ealHtRsos(TP11 K; Canluueftr =Canl.rt(t.eCanl) rs; hneFtr uue hneswiecxgthne(, e) ftr.dLsee(hneFtrLsee.LS) uueaditnrCanluueitnrCOE; } }
  • 24. Creating an HTTP server Gather channels for future closing piaefnlCanlru alhnes=nwDfuthneGop rvt ia hneGop lCanl e ealCanlru( ) ... / aanisd orcso hnlr / gi nie u utm ade casCsoHnlretnsSmlCanlptemade { ls utmade xed ipehneUsraHnlr ... @vrie Oerd pbi vi canlpnCanladeCnetcx Canltt ulc od hneOe(hneHnlrotx t, hneSae Eete trw Ecpin{ vn ) hos xeto Canlcanl=egthne(; hne hne .eCanl) alhnesadcanl; lCanl.d(hne) } }
  • 25. Creating an HTTP server Release resources close gathered channels release external resources alhnescoe)aatnnerpil(; lCanl.ls(.wiUitrutby) bosrprlaexenleore(; otta.eesEtraRsucs)
  • 26. TCPnodelay, TCPkeepalive Remember that bootstrap code? / Otosfriscide -te poesI / pin o t hlrn hy rcs O bosrpstpin"hl.cNDly,tu) otta.eOto(cidtpoea" re; bosrpstpin"hl.eplv" fle; otta.eOto(cidkeAie, as) What do these options mean?
  • 27. TCP keepAlive prolongs each TCP connection makes NAT router happy
  • 28. TCP noDelay Nagle's algorithm glues up small TCP packets tries to reduce bandwidth increases latency
  • 29. TCPnodelay, TCPkeepalive To use, or not to use?
  • 31. Thank you Additional resources netty @ github introductory article