SlideShare a Scribd company logo
Jackson Oliveira
Marcelo Serpa
About me
❏ Software Architect at ilegra
❏ AWS & GCP
❏ Google Cloud Architect Certified
❏ Microservices / DevOPS
❏ Mortal Kombat Player :D
❏ https://github.com/marceloserpa/
❏ https://www.linkedin.com/in/marceloserpa/
About me
❏ Father
❏ Software Architect at ilegra
❏ Devops Engineer Specialist
❏ Google Cloud Architect Certified
❏ SOA Specialist
❏ Football fun
❏ Github
❏ Twitter
❏ Blog
Exercise 1
● Create a TCP server using socket API. Use the template available here.
● It needs to be able to process more than one request at time (use threads)
Let's review what we did and think about It
How works the traditional way
● thread per request model
● One thread for the entire request flow
● limitations 1 thread == 1MB (around it)
Blocking and synchronous
● Sequential
● Unnecessary waiting time
● Total time is high
Expectations for modern applications
● high throughput
● scalability
● lower cost (BE CAREFUL)
Java NIO
● Java abstraction to deal with low level I/O
● Work on top of channels and selectors (scales better)
● Is much more efficient than native sockets and easier to deal with.
Java NIO - Can become complex as well - link
Networking programing
● Is inhirintanly complex
○ It’s more than programming languages or algorithms
○ Requires specific skills
○ Network programs have their own performance requirements
○ Needs to be efficient, otherwise they won't attend the current market requirements.
What is Netty
“Netty is a NIO client server framework which enables quick and easy development
of network applications such as protocol servers and clients. It greatly simplifies
and streamlines network programming such as TCP and UDP socket server.”
● A networking programming server
● open source and written in Java
● Asynchronous and event driven
● Enforces a better design. Decouples business logic from network programming details.
● Configurable
● Extensible
Companies using Netty
● Apple
● Twitter
○ using Finagle their Netty-basead framework in inter-system communication
● Facebook
○ uses Netty in Nifty - Thrift service
● Google
● Square
● Instagram
● Netflix
Companies using Netty - Netflix
Companies using Netty - Twitter
OSS project using Netty
● Infinispan
● HornetQ
● Vert.x
● Apache Cassandra
● ElasticSearch
Cassandra - More nodes, worst the performance
Cassandra - Streaming data between nodes - Before
Cassandra - Streaming data between nodes
Cassandra - Streaming data between nodes - Before
Cassandra - Streaming data between nodes - Before
Cassandra - Streaming data between nodes - Before
Cassandra - Streaming data between nodes - Now
Cassandra - Streaming data between nodes - Now
Startups using Netty
● Firebase
● Urban Airship
Non-Blocking and asynchronous
● Initialize something now
● Using Threads Efficiently
● Scalability
● More efficient (doing more with less resources)
● concurrency
Core components
● EventLoop
● Channel
● Callback
● Future
● Event Handler
Netty - High level arch
Echo Server Example
Echo Server Example
Eventloop impl in use.
There are others...
Echo Server Example
Utility that helps glue
all pieces
Echo Server Example
Transport type defined
for the channel
Echo Server Example
Setting handler on the
pipeline chain
Echo Server Example
Bind the server and
channel and wait this
process complete
Echo Server Example
Block the current
thread and wait until
the channel is closed
Echo Client - Example
Echo Client - Example
What is EventLoop? How it works?
● Threading model
● Control flow
● Dispatching events to ChannelHandlers
EventLoop -Task Scheduling - run later
scheduling task to run
after 10 seconds
EventLoop -Task Scheduling - periodically
scheduling task to run
every 10 seconds
staring in 10 seconds
What is EventLoop group?
● Allocate EventLoop for a Channel
● Uses round-robin to distribute load
● An application needs a
least 1 EventLoopGroup
Channel
● Socket
● Receive events
● Transport layer
● Notify Channel Handlers
ChannelHandler
● Decoupled business from networking
● Implements the logic
● React to event notification
● ChannelInboundHandlerAdapter
○ channelRead()
○ channelReadComplete()
○ exceptionCaught()
● ChannelHandler are invoke for different events
● Hook lifecycle
ChannelFuture
● Non-blocking process
● Attach Future Listener
● Async notification
ChannelPipeline
● chain of ChannelHandler
● propagation flow
● order to execute channel handlers
● ChannelHandler is installed as follow:
○ a Channelnitializaer is registered to server bootstrap
○ when Channelnitializaer.init() is called it install the channels handlers in the pipeline
Bootstraper
for clients (Bootstrap)
● establish connection
● connect to remote peer
● requires only one EventLoopGroup
for servers (ServerBootstrap)
● listening to income connections
● requires two EventLoopGroup:
○ one for ServerChannel
○ others to registered all channel that you
want
Bytebuf
● Byte container
● Alternative for NIO ByteBuffer
● Used to data
Codecs
● Transforms streams of byte from one
format to another
Encoder Decoder
Codec Example - Bootstrap
Creating a
ServerBootstrap and
registered
EventLoopGroup
Codec Example - Bootstrap
Registered Initializer
to configure Pipeline
Codec Example
Registered codecs
and aggregator on
ChannelPipeline
Codec Example - Handler part 1
Use decoder to extract
parameters
Codec Example - Handler part 1
Call service to handle
business rules
Codec Example - Handler part 2
Solution based Netty - ServiceTalk
https://github.com/diegopacheco/java-pocs/tree/master/pocs/servicetalk-fun
Solution based Netty - ServiceTalk
● gRPC
● HTTP/2
● Long-polling
● Smart Client
○ Client side load balancing
○ retry
● Modularization
○ use just you need
Solution based Netty - Armeria
https://github.com/diegopacheco/java-pocs/tree/master/pocs/armerica-fun/src/main/java
Solution based Netty - Armeria
● HTTP/2
● Integration with gRPC and Thrift
● Metrics
● Circuit breaker
● Client-side health-check, retries and client side load balancing
● Distributed Tracing with Zipkin
● Service discovery (DNS and Zookeeper)
● Built on top of Reactive Streams and Java 8 CompletableFuture
Solution based Netty - Reactor Netty
https://github.com/diegopacheco/java-pocs/tree/master/pocs/reactor-netty-simple
Solution based Netty - Reactor Netty
● Support reactive streams specification
● HTTP, UDP and TCP
● Schedulers
● Parallel Flux
Performance/Scalability > Developer Experience
● Number of lines of code is not a problem
● IFs (if not shells) is not a problem
● You don't deal with this code everyday
● There are books and materials on the web (stack overflow, etc...)
● Less lines of code does not means is better
● Spring might be “feeling” better but has worst performances and more deps
● Developers should care more about the business
○ User Experience -> slow server
○ Cost Reduction -> doing more with less(less cpu and memory used - more toughtput)
○ Reliability -> netty is battle tested by Silicon valley biggest IT companies in the world.
Netty
Thank you!
Exercise 2
● Change the code made on exercise 1, this time using Netty as a a server
implementation and client.
● Use this template in order to get started.
Exercise 3
● For this exercise we are gonna use same problem as described on exercise
2, but this time using an http interface rather than exposing an TCP socket.
● Server should be called like this:
localhost:8080/training/netty/sum?num1=1&num2=4
● Use this template in order to get started.
Exercise 4
● Do the same implementation of exercise 3 using ServiceTalk with JaxRS
● Use this template in order to get started.

More Related Content

PDF
Netty training
Marcelo Serpa
 
PDF
PyConIE 2017 Writing and deploying serverless python applications
Cesar Cardenas Desales
 
PDF
S3, Cassandra or Outer Space? Dumping Time Series Data using Spark - Demi Be...
Codemotion
 
ODP
Container orchestration: the cold war - Giulio De Donato - Codemotion Rome 2017
Codemotion
 
PDF
NetflixOSS Meetup season 3 episode 1
Ruslan Meshenberg
 
PDF
Architectural caching patterns for kubernetes
Rafał Leszko
 
PDF
Netflix Keystone - How Netflix Handles Data Streams up to 11M Events/Sec
Peter Bakas
 
PDF
Tracing Microservices with Zipkin
takezoe
 
Netty training
Marcelo Serpa
 
PyConIE 2017 Writing and deploying serverless python applications
Cesar Cardenas Desales
 
S3, Cassandra or Outer Space? Dumping Time Series Data using Spark - Demi Be...
Codemotion
 
Container orchestration: the cold war - Giulio De Donato - Codemotion Rome 2017
Codemotion
 
NetflixOSS Meetup season 3 episode 1
Ruslan Meshenberg
 
Architectural caching patterns for kubernetes
Rafał Leszko
 
Netflix Keystone - How Netflix Handles Data Streams up to 11M Events/Sec
Peter Bakas
 
Tracing Microservices with Zipkin
takezoe
 

What's hot (20)

PDF
Writing and deploying serverless python applications
Cesar Cardenas Desales
 
PDF
Netflix Keystone Pipeline at Big Data Bootcamp, Santa Clara, Nov 2015
Monal Daxini
 
PDF
NATS in action - A Real time Microservices Architecture handled by NATS
Raül Pérez
 
PDF
Netflix at-disney-09-26-2014
Monal Daxini
 
PDF
Concurrency, Parallelism And IO
Piyush Katariya
 
PDF
Docker primer and tips
Samuel Chow
 
PDF
Thinking Functionally with Clojure
John Stevenson
 
PDF
AWS Lambda and serverless Java | DevNation Live
Red Hat Developers
 
PDF
PostgreSQL Sharding and HA: Theory and Practice (PGConf.ASIA 2017)
Aleksander Alekseev
 
PDF
Manuel Hurtado. Couchbase paradigma4oct
Paradigma Digital
 
PDF
Architectural caching patterns for kubernetes
Rafał Leszko
 
PDF
Terraforming your Infrastructure on GCP
Samuel Chow
 
PPTX
Nashorn: JavaScript that doesn't suck - Tomer Gabel, Wix
Codemotion Tel Aviv
 
PDF
USENIX LISA15: How TubeMogul Handles over One Trillion HTTP Requests a Month
Nicolas Brousse
 
PPTX
Open stack HA - Theory to Reality
Sriram Subramanian
 
PPTX
Honest Performance Testing with "NDBench" (Vinay Chella, Netflix) | Cassandra...
DataStax
 
PDF
The benefits of running Spark on your own Docker
Itai Yaffe
 
PDF
PyConIT 2018 Writing and deploying serverless python applications
Cesar Cardenas Desales
 
PDF
Clusternaut: Orchestrating  Percona XtraDB Cluster with Kubernetes
Raghavendra Prabhu
 
PDF
Heroku to Kubernetes & Gihub to Gitlab success story
Jérémy Wimsingues
 
Writing and deploying serverless python applications
Cesar Cardenas Desales
 
Netflix Keystone Pipeline at Big Data Bootcamp, Santa Clara, Nov 2015
Monal Daxini
 
NATS in action - A Real time Microservices Architecture handled by NATS
Raül Pérez
 
Netflix at-disney-09-26-2014
Monal Daxini
 
Concurrency, Parallelism And IO
Piyush Katariya
 
Docker primer and tips
Samuel Chow
 
Thinking Functionally with Clojure
John Stevenson
 
AWS Lambda and serverless Java | DevNation Live
Red Hat Developers
 
PostgreSQL Sharding and HA: Theory and Practice (PGConf.ASIA 2017)
Aleksander Alekseev
 
Manuel Hurtado. Couchbase paradigma4oct
Paradigma Digital
 
Architectural caching patterns for kubernetes
Rafał Leszko
 
Terraforming your Infrastructure on GCP
Samuel Chow
 
Nashorn: JavaScript that doesn't suck - Tomer Gabel, Wix
Codemotion Tel Aviv
 
USENIX LISA15: How TubeMogul Handles over One Trillion HTTP Requests a Month
Nicolas Brousse
 
Open stack HA - Theory to Reality
Sriram Subramanian
 
Honest Performance Testing with "NDBench" (Vinay Chella, Netflix) | Cassandra...
DataStax
 
The benefits of running Spark on your own Docker
Itai Yaffe
 
PyConIT 2018 Writing and deploying serverless python applications
Cesar Cardenas Desales
 
Clusternaut: Orchestrating  Percona XtraDB Cluster with Kubernetes
Raghavendra Prabhu
 
Heroku to Kubernetes & Gihub to Gitlab success story
Jérémy Wimsingues
 
Ad

Similar to Netty training (20)

PPTX
Netty Notes Part 3 - Channel Pipeline and EventLoops
Rick Hightower
 
PDF
Netty In Action 1st Edition Norman Maurer Marvin Allen Wolfthal
mpleteang
 
PDF
Netty from the trenches
Jordi Gerona
 
PDF
Building scalable network applications with Netty (as presented on NLJUG JFal...
Jaap ter Woerds
 
PDF
Building scalable network applications with Netty
NLJUG
 
PPT
Netty 4-based RPC System Development
Allan Huang
 
PDF
Vert.x – The problem of real-time data binding
Alex Derkach
 
PDF
Asynchronous Architectures for Implementing Scalable Cloud Services - Evan Co...
Twilio Inc
 
PDF
Building Web APIs that Scale
Salesforce Developers
 
PPTX
Notes on Netty baics
Rick Hightower
 
ODP
Building Netty Servers
Dani Solà Lagares
 
PDF
Netty - a pragmatic introduction
Raphael Stary
 
PDF
Netty: asynchronous data transfer
Victor Cherkassky
 
PDF
Vert.x introduction
GR8Conf
 
PPTX
Event driven systems
Shatabda Majumdar
 
PDF
Twisted
Michal Sedlak
 
ODP
Groovy & Grails eXchange 2012 vert.x presentation
Stuart (Pid) Williams
 
PPTX
Vert.x devoxx london 2013
Stuart (Pid) Williams
 
PPTX
vert.x - asynchronous event-driven web applications on the JVM
jbandi
 
PDF
Java Network Programming Third Edition 3rd Edition Elliotte Rusty Harold
dxvpbvqlbt970
 
Netty Notes Part 3 - Channel Pipeline and EventLoops
Rick Hightower
 
Netty In Action 1st Edition Norman Maurer Marvin Allen Wolfthal
mpleteang
 
Netty from the trenches
Jordi Gerona
 
Building scalable network applications with Netty (as presented on NLJUG JFal...
Jaap ter Woerds
 
Building scalable network applications with Netty
NLJUG
 
Netty 4-based RPC System Development
Allan Huang
 
Vert.x – The problem of real-time data binding
Alex Derkach
 
Asynchronous Architectures for Implementing Scalable Cloud Services - Evan Co...
Twilio Inc
 
Building Web APIs that Scale
Salesforce Developers
 
Notes on Netty baics
Rick Hightower
 
Building Netty Servers
Dani Solà Lagares
 
Netty - a pragmatic introduction
Raphael Stary
 
Netty: asynchronous data transfer
Victor Cherkassky
 
Vert.x introduction
GR8Conf
 
Event driven systems
Shatabda Majumdar
 
Twisted
Michal Sedlak
 
Groovy & Grails eXchange 2012 vert.x presentation
Stuart (Pid) Williams
 
Vert.x devoxx london 2013
Stuart (Pid) Williams
 
vert.x - asynchronous event-driven web applications on the JVM
jbandi
 
Java Network Programming Third Edition 3rd Edition Elliotte Rusty Harold
dxvpbvqlbt970
 
Ad

More from Jackson dos Santos Olveira (20)

PDF
AWS Control Tower
Jackson dos Santos Olveira
 
PDF
An introduction to predictionIO
Jackson dos Santos Olveira
 
PDF
Introduction to HashiCorp Consul
Jackson dos Santos Olveira
 
PDF
Apache mahout - introduction
Jackson dos Santos Olveira
 
PDF
Managing computational resources with Apache Mesos
Jackson dos Santos Olveira
 
PDF
Introduction to CFEngine
Jackson dos Santos Olveira
 
PDF
DBC Principles
Jackson dos Santos Olveira
 
PDF
Jboss Teiid - The data you have on the place you need
Jackson dos Santos Olveira
 
PDF
Apache PIG introduction
Jackson dos Santos Olveira
 
PPSX
Jboss AS7 New Main Features
Jackson dos Santos Olveira
 
PPSX
Celery Introduction
Jackson dos Santos Olveira
 
PPT
Elastic search introduction
Jackson dos Santos Olveira
 
PPT
Presentation about ClosureScript fraemework
Jackson dos Santos Olveira
 
AWS Control Tower
Jackson dos Santos Olveira
 
An introduction to predictionIO
Jackson dos Santos Olveira
 
Introduction to HashiCorp Consul
Jackson dos Santos Olveira
 
Apache mahout - introduction
Jackson dos Santos Olveira
 
Managing computational resources with Apache Mesos
Jackson dos Santos Olveira
 
Introduction to CFEngine
Jackson dos Santos Olveira
 
Jboss Teiid - The data you have on the place you need
Jackson dos Santos Olveira
 
Apache PIG introduction
Jackson dos Santos Olveira
 
Jboss AS7 New Main Features
Jackson dos Santos Olveira
 
Celery Introduction
Jackson dos Santos Olveira
 
Elastic search introduction
Jackson dos Santos Olveira
 
Presentation about ClosureScript fraemework
Jackson dos Santos Olveira
 

Recently uploaded (20)

PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PDF
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
PPTX
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
PDF
Software Development Methodologies in 2025
KodekX
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PPTX
Simple and concise overview about Quantum computing..pptx
mughal641
 
PDF
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
PDF
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
PDF
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PDF
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PDF
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
PDF
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
PDF
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 
PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
Software Development Methodologies in 2025
KodekX
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
Simple and concise overview about Quantum computing..pptx
mughal641
 
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 

Netty training

  • 2. About me ❏ Software Architect at ilegra ❏ AWS & GCP ❏ Google Cloud Architect Certified ❏ Microservices / DevOPS ❏ Mortal Kombat Player :D ❏ https://github.com/marceloserpa/ ❏ https://www.linkedin.com/in/marceloserpa/
  • 3. About me ❏ Father ❏ Software Architect at ilegra ❏ Devops Engineer Specialist ❏ Google Cloud Architect Certified ❏ SOA Specialist ❏ Football fun ❏ Github ❏ Twitter ❏ Blog
  • 4. Exercise 1 ● Create a TCP server using socket API. Use the template available here. ● It needs to be able to process more than one request at time (use threads)
  • 5. Let's review what we did and think about It
  • 6. How works the traditional way ● thread per request model ● One thread for the entire request flow ● limitations 1 thread == 1MB (around it)
  • 7. Blocking and synchronous ● Sequential ● Unnecessary waiting time ● Total time is high
  • 8. Expectations for modern applications ● high throughput ● scalability ● lower cost (BE CAREFUL)
  • 9. Java NIO ● Java abstraction to deal with low level I/O ● Work on top of channels and selectors (scales better) ● Is much more efficient than native sockets and easier to deal with.
  • 10. Java NIO - Can become complex as well - link
  • 11. Networking programing ● Is inhirintanly complex ○ It’s more than programming languages or algorithms ○ Requires specific skills ○ Network programs have their own performance requirements ○ Needs to be efficient, otherwise they won't attend the current market requirements.
  • 12. What is Netty “Netty is a NIO client server framework which enables quick and easy development of network applications such as protocol servers and clients. It greatly simplifies and streamlines network programming such as TCP and UDP socket server.” ● A networking programming server ● open source and written in Java ● Asynchronous and event driven ● Enforces a better design. Decouples business logic from network programming details. ● Configurable ● Extensible
  • 13. Companies using Netty ● Apple ● Twitter ○ using Finagle their Netty-basead framework in inter-system communication ● Facebook ○ uses Netty in Nifty - Thrift service ● Google ● Square ● Instagram ● Netflix
  • 16. OSS project using Netty ● Infinispan ● HornetQ ● Vert.x ● Apache Cassandra ● ElasticSearch
  • 17. Cassandra - More nodes, worst the performance
  • 18. Cassandra - Streaming data between nodes - Before
  • 19. Cassandra - Streaming data between nodes
  • 20. Cassandra - Streaming data between nodes - Before
  • 21. Cassandra - Streaming data between nodes - Before
  • 22. Cassandra - Streaming data between nodes - Before
  • 23. Cassandra - Streaming data between nodes - Now
  • 24. Cassandra - Streaming data between nodes - Now
  • 25. Startups using Netty ● Firebase ● Urban Airship
  • 26. Non-Blocking and asynchronous ● Initialize something now ● Using Threads Efficiently ● Scalability ● More efficient (doing more with less resources) ● concurrency
  • 27. Core components ● EventLoop ● Channel ● Callback ● Future ● Event Handler
  • 28. Netty - High level arch
  • 30. Echo Server Example Eventloop impl in use. There are others...
  • 31. Echo Server Example Utility that helps glue all pieces
  • 32. Echo Server Example Transport type defined for the channel
  • 33. Echo Server Example Setting handler on the pipeline chain
  • 34. Echo Server Example Bind the server and channel and wait this process complete
  • 35. Echo Server Example Block the current thread and wait until the channel is closed
  • 36. Echo Client - Example
  • 37. Echo Client - Example
  • 38. What is EventLoop? How it works? ● Threading model ● Control flow ● Dispatching events to ChannelHandlers
  • 39. EventLoop -Task Scheduling - run later scheduling task to run after 10 seconds
  • 40. EventLoop -Task Scheduling - periodically scheduling task to run every 10 seconds staring in 10 seconds
  • 41. What is EventLoop group? ● Allocate EventLoop for a Channel ● Uses round-robin to distribute load ● An application needs a least 1 EventLoopGroup
  • 42. Channel ● Socket ● Receive events ● Transport layer ● Notify Channel Handlers
  • 43. ChannelHandler ● Decoupled business from networking ● Implements the logic ● React to event notification ● ChannelInboundHandlerAdapter ○ channelRead() ○ channelReadComplete() ○ exceptionCaught() ● ChannelHandler are invoke for different events ● Hook lifecycle
  • 44. ChannelFuture ● Non-blocking process ● Attach Future Listener ● Async notification
  • 45. ChannelPipeline ● chain of ChannelHandler ● propagation flow ● order to execute channel handlers ● ChannelHandler is installed as follow: ○ a Channelnitializaer is registered to server bootstrap ○ when Channelnitializaer.init() is called it install the channels handlers in the pipeline
  • 46. Bootstraper for clients (Bootstrap) ● establish connection ● connect to remote peer ● requires only one EventLoopGroup for servers (ServerBootstrap) ● listening to income connections ● requires two EventLoopGroup: ○ one for ServerChannel ○ others to registered all channel that you want
  • 47. Bytebuf ● Byte container ● Alternative for NIO ByteBuffer ● Used to data
  • 48. Codecs ● Transforms streams of byte from one format to another Encoder Decoder
  • 49. Codec Example - Bootstrap Creating a ServerBootstrap and registered EventLoopGroup
  • 50. Codec Example - Bootstrap Registered Initializer to configure Pipeline
  • 51. Codec Example Registered codecs and aggregator on ChannelPipeline
  • 52. Codec Example - Handler part 1 Use decoder to extract parameters
  • 53. Codec Example - Handler part 1 Call service to handle business rules
  • 54. Codec Example - Handler part 2
  • 55. Solution based Netty - ServiceTalk https://github.com/diegopacheco/java-pocs/tree/master/pocs/servicetalk-fun
  • 56. Solution based Netty - ServiceTalk ● gRPC ● HTTP/2 ● Long-polling ● Smart Client ○ Client side load balancing ○ retry ● Modularization ○ use just you need
  • 57. Solution based Netty - Armeria https://github.com/diegopacheco/java-pocs/tree/master/pocs/armerica-fun/src/main/java
  • 58. Solution based Netty - Armeria ● HTTP/2 ● Integration with gRPC and Thrift ● Metrics ● Circuit breaker ● Client-side health-check, retries and client side load balancing ● Distributed Tracing with Zipkin ● Service discovery (DNS and Zookeeper) ● Built on top of Reactive Streams and Java 8 CompletableFuture
  • 59. Solution based Netty - Reactor Netty https://github.com/diegopacheco/java-pocs/tree/master/pocs/reactor-netty-simple
  • 60. Solution based Netty - Reactor Netty ● Support reactive streams specification ● HTTP, UDP and TCP ● Schedulers ● Parallel Flux
  • 61. Performance/Scalability > Developer Experience ● Number of lines of code is not a problem ● IFs (if not shells) is not a problem ● You don't deal with this code everyday ● There are books and materials on the web (stack overflow, etc...) ● Less lines of code does not means is better ● Spring might be “feeling” better but has worst performances and more deps ● Developers should care more about the business ○ User Experience -> slow server ○ Cost Reduction -> doing more with less(less cpu and memory used - more toughtput) ○ Reliability -> netty is battle tested by Silicon valley biggest IT companies in the world.
  • 63. Exercise 2 ● Change the code made on exercise 1, this time using Netty as a a server implementation and client. ● Use this template in order to get started.
  • 64. Exercise 3 ● For this exercise we are gonna use same problem as described on exercise 2, but this time using an http interface rather than exposing an TCP socket. ● Server should be called like this: localhost:8080/training/netty/sum?num1=1&num2=4 ● Use this template in order to get started.
  • 65. Exercise 4 ● Do the same implementation of exercise 3 using ServiceTalk with JaxRS ● Use this template in order to get started.