SlideShare una empresa de Scribd logo
1 de 29
Descargar para leer sin conexión
Building High Performance
Scalable TCP/IP Servers with
Apache MINA
Originally presented at ApacheCon Europe 2006 in Dublin

Latest slides and code samples at http://people.apache.org/~proyal

Presented by Peter Royal, <proyal@apache.org>




                                                                     1
Goals of this presentation
•Introduction to MINA
•Demonstration of what it can do
•Converting blocking-IO code to MINA
•Hopefully inspire you to use it :)




                                       2
What is MINA
•Multipurpose Infrastructure for Networked Applications
•A framework (the F word!) for building networked clients
 and servers based on non-blocking IO
•http://directory.apache.org/subprojects/mina/




                                                            3
Brief history of MINA
•Started out as Netty2 from Trustin Lee
•Joined the Directory Project as the SEDA-based directory
 needed an asynchronous I/O layer.




                                                            4
IoHandler




             IoFilter




                         Inbound
             IoFilter
Outbound




             IoFilter




           IoProcessor


           IoAcceptor




           Network
                                   Architectural overview

                                                        5
IoSession
•Holder of state for a connection (either client-side or
 server-side)
•Passed along with every event
•Important Methods
  •write
  •close
  •get/setAttribute




                                                           6
IoHandler
•Akin to a Servlet           IoHandler



•Endpoint of a filter chain
                               IoFilter


•Important Methods
                               IoFilter


  •sessionOpened
                               IoFilter

  •messageReceived
                             IoProcessor

  •sessionClosed
                             IoAcceptor




                                           7
IoFilterChain
•Chain of IoFilter's for each IoSession
•Can setup template chains per IoConnector/IoAcceptor
•Dynamic addition/removal




                                                        8
IoFilters
•Akin to a ServletFilter            IoHandler



•View/Hack/Slash the event stream
                                      IoFilter


•Important Methods
                                      IoFilter


  •sessionOpened
                                      IoFilter

  •messageReceived
                                    IoProcessor

  •filterWrite
                                    IoAcceptor


  •sessionClosed



                                                  9
IoAcceptor
•Server-side entry point.                IoHandler



•Accepts incoming connections and fires
                                           IoFilter
 events to an IoHandler
•Important Methods                         IoFilter




  •bind                                    IoFilter




                                         IoProcessor


                                         IoAcceptor




                                                       10
IoConnector
•Client-side entry point
•Initiate connections to a remote service, and fires events to
 an IoHandler
•Important Methods
  •connect




                                                                11
IoProcessor
•Internal component                       IoHandler



•Handles reading and writing data to an
                                            IoFilter
 underlying connection
•Each connection is associated with a       IoFilter



 single IoProcessor (shared amongst
                                            IoFilter
 multiple connections)
                                          IoProcessor


                                          IoAcceptor




                                                        12
Our Sample Application
•Persistent connections from clients
•Serialize java objects across the wire
•Clients connect and are given a unit of work, which in this
 case, is just an instruction for how long to wait until getting
 their next instruction.




                                                                   13
Monitoring Performance
•Thread activity via jconsole
•CPU Activity via Activity Monitor
  •(or your favorite tool)




                                     14
Limitations

              15
Scalability
•JVM limit on number of threads
•The lovely java.lang.OutOfMemoryError: unable to
 create new native thread




                                                    16
Lets convert to MINA!
•Server side first
  •(Client to come soon)




                           17
Re-testing

             18
New Limitations?
•Java Serialization takes up CPU time
  •(a profiler would reveal this)
•OS limit of per-process open files
  •(consult the documentation for your OS)
  •sysctl / ulimit to view/change on unix-like systems




                                                         19
MINA on the client
•Since we will be using MINA's built-in support for building
 protocols, the ProtocolCodecFilter
  •Any socket client can talk to MINA
  •We’re using MINA on both sides for simplicity in our
   examples.




                                                               20
Client is just like the server
•IoHandler and IoFilter's
•Can re-use filters on both client and server sides.




                                                      21
Implementing the protocol.

                             22
It still works!

                  23
Filters that ship today
•Logging
•Compression
•Blacklist
•SSL
  •Requires Java 5




                          24
Filters we are working on
•Traffic Shaping
•Rate Limiting
•Performance Monitoring




                            25
Some things built on MINA
•LDAP - Apache DS <http://directory.apache.org/
 subprojects/apacheds/index.html>

•Flash - red5 <http://www.osflash.org/red5>

•HTTP - AsyncWeb <http://asyncweb.safehaus.org/>




                                                   26
Performance Tips
•Set the number of IoProcessor’s to be equal to the number
 of CPU cores.

•Benchmark! Users have found both heap and direct
 buffers, pooled and not pooled, to be beneficial depending
 on their workloads.

•For ultra-low latency with small message sizes on a local
 lan, disable Nagle’s algorithm; the TCP_NODELAY flag.




                                                             27
Questions?

             28
Thank You!

             29

Más contenido relacionado

La actualidad más candente

Giới thiệu dự án Phúc Đạt Tower Bình Dương
Giới thiệu dự án Phúc Đạt Tower Bình DươngGiới thiệu dự án Phúc Đạt Tower Bình Dương
Giới thiệu dự án Phúc Đạt Tower Bình DươngKhoaLee7
 
Meyer-Sound-Constellation-Tallinn-Estonia.Case-Study[1].pdf
Meyer-Sound-Constellation-Tallinn-Estonia.Case-Study[1].pdfMeyer-Sound-Constellation-Tallinn-Estonia.Case-Study[1].pdf
Meyer-Sound-Constellation-Tallinn-Estonia.Case-Study[1].pdfIshpal Singh
 
Introduction to German A1 for Certification exam
Introduction to German A1 for Certification examIntroduction to German A1 for Certification exam
Introduction to German A1 for Certification examJeshuruntheetla
 
On plans : important architecture floor plans VER.1
On plans : important architecture floor plans VER.1On plans : important architecture floor plans VER.1
On plans : important architecture floor plans VER.1Yoontaek Lim
 
Princess Tower Brochure English
Princess Tower Brochure EnglishPrincess Tower Brochure English
Princess Tower Brochure EnglishNGM Real Estate
 

La actualidad más candente (7)

Beats
BeatsBeats
Beats
 
Giới thiệu dự án Phúc Đạt Tower Bình Dương
Giới thiệu dự án Phúc Đạt Tower Bình DươngGiới thiệu dự án Phúc Đạt Tower Bình Dương
Giới thiệu dự án Phúc Đạt Tower Bình Dương
 
Dufour interior design
Dufour interior designDufour interior design
Dufour interior design
 
Meyer-Sound-Constellation-Tallinn-Estonia.Case-Study[1].pdf
Meyer-Sound-Constellation-Tallinn-Estonia.Case-Study[1].pdfMeyer-Sound-Constellation-Tallinn-Estonia.Case-Study[1].pdf
Meyer-Sound-Constellation-Tallinn-Estonia.Case-Study[1].pdf
 
Introduction to German A1 for Certification exam
Introduction to German A1 for Certification examIntroduction to German A1 for Certification exam
Introduction to German A1 for Certification exam
 
On plans : important architecture floor plans VER.1
On plans : important architecture floor plans VER.1On plans : important architecture floor plans VER.1
On plans : important architecture floor plans VER.1
 
Princess Tower Brochure English
Princess Tower Brochure EnglishPrincess Tower Brochure English
Princess Tower Brochure English
 

Destacado

Apache MINA: The high-performance protocol construction toolkit.
Apache MINA: The high-performance protocol construction toolkit.Apache MINA: The high-performance protocol construction toolkit.
Apache MINA: The high-performance protocol construction toolkit.osi
 
Rapid Network Application Development with Apache MINA
Rapid Network Application Development with Apache MINARapid Network Application Development with Apache MINA
Rapid Network Application Development with Apache MINAtrustinlee
 
Apache Mina
Apache MinaApache Mina
Apache Minalake xie
 
Nio sur Netty par Mouhcine Moulou - 3 avril 2014
Nio sur Netty par Mouhcine Moulou - 3 avril 2014Nio sur Netty par Mouhcine Moulou - 3 avril 2014
Nio sur Netty par Mouhcine Moulou - 3 avril 2014SOAT
 
Chalet management system (e cha m)
Chalet management system (e cha m)Chalet management system (e cha m)
Chalet management system (e cha m)HoneySah
 
Intro to Distributed Database Management System
Intro to Distributed Database Management SystemIntro to Distributed Database Management System
Intro to Distributed Database Management SystemAli Raza
 
Programming TCP/IP with Sockets
Programming TCP/IP with SocketsProgramming TCP/IP with Sockets
Programming TCP/IP with Socketselliando dias
 
Distributed Databases
Distributed DatabasesDistributed Databases
Distributed Databaseselliando dias
 
Lecture 11 - distributed database
Lecture 11 - distributed databaseLecture 11 - distributed database
Lecture 11 - distributed databaseHoneySah
 
Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slideselliando dias
 
Distributed Database Management System
Distributed Database Management SystemDistributed Database Management System
Distributed Database Management SystemHardik Patil
 
Socket Programming Tutorial
Socket Programming TutorialSocket Programming Tutorial
Socket Programming TutorialJignesh Patel
 
Distributed Database System
Distributed Database SystemDistributed Database System
Distributed Database SystemSulemang
 

Destacado (18)

Apache MINA: The high-performance protocol construction toolkit.
Apache MINA: The high-performance protocol construction toolkit.Apache MINA: The high-performance protocol construction toolkit.
Apache MINA: The high-performance protocol construction toolkit.
 
Mina2
Mina2Mina2
Mina2
 
Rapid Network Application Development with Apache MINA
Rapid Network Application Development with Apache MINARapid Network Application Development with Apache MINA
Rapid Network Application Development with Apache MINA
 
Introduction to Apache MINA
Introduction to Apache MINAIntroduction to Apache MINA
Introduction to Apache MINA
 
Apache Mina
Apache MinaApache Mina
Apache Mina
 
NIO 2
NIO 2NIO 2
NIO 2
 
Nio sur Netty par Mouhcine Moulou - 3 avril 2014
Nio sur Netty par Mouhcine Moulou - 3 avril 2014Nio sur Netty par Mouhcine Moulou - 3 avril 2014
Nio sur Netty par Mouhcine Moulou - 3 avril 2014
 
Chalet management system (e cha m)
Chalet management system (e cha m)Chalet management system (e cha m)
Chalet management system (e cha m)
 
Intro to Distributed Database Management System
Intro to Distributed Database Management SystemIntro to Distributed Database Management System
Intro to Distributed Database Management System
 
Programming TCP/IP with Sockets
Programming TCP/IP with SocketsProgramming TCP/IP with Sockets
Programming TCP/IP with Sockets
 
Distributed Databases
Distributed DatabasesDistributed Databases
Distributed Databases
 
Database fragmentation
Database fragmentationDatabase fragmentation
Database fragmentation
 
Lecture 11 - distributed database
Lecture 11 - distributed databaseLecture 11 - distributed database
Lecture 11 - distributed database
 
Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slides
 
Distributed Database Management System
Distributed Database Management SystemDistributed Database Management System
Distributed Database Management System
 
Socket Programming Tutorial
Socket Programming TutorialSocket Programming Tutorial
Socket Programming Tutorial
 
Distributed database
Distributed databaseDistributed database
Distributed database
 
Distributed Database System
Distributed Database SystemDistributed Database System
Distributed Database System
 

Similar a Building High Performance Scalable TCP/IP Servers with Apache MINA

JDK 8 and JDK 8 Updates in OpenJDK
JDK 8 and JDK 8 Updates in OpenJDKJDK 8 and JDK 8 Updates in OpenJDK
JDK 8 and JDK 8 Updates in OpenJDKWolfgang Weigend
 
CrossWorlds: Unleash the Power of Domino for Connections Development
CrossWorlds: Unleash the Power of Domino for Connections Development CrossWorlds: Unleash the Power of Domino for Connections Development
CrossWorlds: Unleash the Power of Domino for Connections Development LetsConnect
 
MySQL: From Single Instance to Big Data
MySQL: From Single Instance to Big DataMySQL: From Single Instance to Big Data
MySQL: From Single Instance to Big DataMorgan Tocker
 
NFV Infrastructure Manager with High Performance Software Switch Lagopus
NFV Infrastructure Manager with High Performance Software Switch Lagopus NFV Infrastructure Manager with High Performance Software Switch Lagopus
NFV Infrastructure Manager with High Performance Software Switch Lagopus Hirofumi Ichihara
 
AFNetworking
AFNetworking AFNetworking
AFNetworking joaopmaia
 
026 Neo4j Data Loading (ETL_ELT) Best Practices - NODES2022 AMERICAS Advanced...
026 Neo4j Data Loading (ETL_ELT) Best Practices - NODES2022 AMERICAS Advanced...026 Neo4j Data Loading (ETL_ELT) Best Practices - NODES2022 AMERICAS Advanced...
026 Neo4j Data Loading (ETL_ELT) Best Practices - NODES2022 AMERICAS Advanced...Neo4j
 
Gradual migration to MicroProfile
Gradual migration to MicroProfileGradual migration to MicroProfile
Gradual migration to MicroProfileRudy De Busscher
 
Gradual Migration to MicroProfile
Gradual Migration to MicroProfileGradual Migration to MicroProfile
Gradual Migration to MicroProfilePayara
 
The First Mile -- Edge and IoT Data Collection with Apache NiFi and MiNiFi
The First Mile -- Edge and IoT Data Collection with Apache NiFi and MiNiFiThe First Mile -- Edge and IoT Data Collection with Apache NiFi and MiNiFi
The First Mile -- Edge and IoT Data Collection with Apache NiFi and MiNiFiDataWorks Summit
 
컨테이너 기술 소개 - Warden, Garden, Docker
컨테이너 기술 소개 - Warden, Garden, Docker컨테이너 기술 소개 - Warden, Garden, Docker
컨테이너 기술 소개 - Warden, Garden, Dockerseungdon Choi
 
The First Mile - Edge and IoT Data Collection With Apache Nifi and MiniFi
The First Mile - Edge and IoT Data Collection With Apache Nifi and MiniFiThe First Mile - Edge and IoT Data Collection With Apache Nifi and MiniFi
The First Mile - Edge and IoT Data Collection With Apache Nifi and MiniFiDataWorks Summit
 
Ext osad initial-eval-march2015
Ext osad initial-eval-march2015Ext osad initial-eval-march2015
Ext osad initial-eval-march2015Daneyon Hansen
 
Apache Geode Meetup, London
Apache Geode Meetup, LondonApache Geode Meetup, London
Apache Geode Meetup, LondonApache Geode
 
Build software like a bag of marbles, not a castle of LEGO®
Build software like a bag of marbles, not a castle of LEGO®Build software like a bag of marbles, not a castle of LEGO®
Build software like a bag of marbles, not a castle of LEGO®Hannes Lowette
 
BYOP: Custom Processor Development with Apache NiFi
BYOP: Custom Processor Development with Apache NiFiBYOP: Custom Processor Development with Apache NiFi
BYOP: Custom Processor Development with Apache NiFiDataWorks Summit
 
2.0 Client Libraries & Using the Java Client by Noah Crowley, Developer Advoc...
2.0 Client Libraries & Using the Java Client by Noah Crowley, Developer Advoc...2.0 Client Libraries & Using the Java Client by Noah Crowley, Developer Advoc...
2.0 Client Libraries & Using the Java Client by Noah Crowley, Developer Advoc...InfluxData
 
Using the Java Client Library by Noah Crowley, DevRel | InfluxData
Using the Java Client Library by Noah Crowley, DevRel | InfluxDataUsing the Java Client Library by Noah Crowley, DevRel | InfluxData
Using the Java Client Library by Noah Crowley, DevRel | InfluxDataInfluxData
 
Road to NODES - Handling Neo4j Data with Apache Hop
Road to NODES - Handling Neo4j Data with Apache HopRoad to NODES - Handling Neo4j Data with Apache Hop
Road to NODES - Handling Neo4j Data with Apache HopNeo4j
 
Social Connections 2015 CrossWorlds and Domino
Social Connections 2015 CrossWorlds and DominoSocial Connections 2015 CrossWorlds and Domino
Social Connections 2015 CrossWorlds and DominoPaul Withers
 

Similar a Building High Performance Scalable TCP/IP Servers with Apache MINA (20)

JDK 8 and JDK 8 Updates in OpenJDK
JDK 8 and JDK 8 Updates in OpenJDKJDK 8 and JDK 8 Updates in OpenJDK
JDK 8 and JDK 8 Updates in OpenJDK
 
CrossWorlds: Unleash the Power of Domino for Connections Development
CrossWorlds: Unleash the Power of Domino for Connections Development CrossWorlds: Unleash the Power of Domino for Connections Development
CrossWorlds: Unleash the Power of Domino for Connections Development
 
MySQL: From Single Instance to Big Data
MySQL: From Single Instance to Big DataMySQL: From Single Instance to Big Data
MySQL: From Single Instance to Big Data
 
NFV Infrastructure Manager with High Performance Software Switch Lagopus
NFV Infrastructure Manager with High Performance Software Switch Lagopus NFV Infrastructure Manager with High Performance Software Switch Lagopus
NFV Infrastructure Manager with High Performance Software Switch Lagopus
 
AFNetworking
AFNetworking AFNetworking
AFNetworking
 
026 Neo4j Data Loading (ETL_ELT) Best Practices - NODES2022 AMERICAS Advanced...
026 Neo4j Data Loading (ETL_ELT) Best Practices - NODES2022 AMERICAS Advanced...026 Neo4j Data Loading (ETL_ELT) Best Practices - NODES2022 AMERICAS Advanced...
026 Neo4j Data Loading (ETL_ELT) Best Practices - NODES2022 AMERICAS Advanced...
 
Gradual migration to MicroProfile
Gradual migration to MicroProfileGradual migration to MicroProfile
Gradual migration to MicroProfile
 
Gradual Migration to MicroProfile
Gradual Migration to MicroProfileGradual Migration to MicroProfile
Gradual Migration to MicroProfile
 
The First Mile -- Edge and IoT Data Collection with Apache NiFi and MiNiFi
The First Mile -- Edge and IoT Data Collection with Apache NiFi and MiNiFiThe First Mile -- Edge and IoT Data Collection with Apache NiFi and MiNiFi
The First Mile -- Edge and IoT Data Collection with Apache NiFi and MiNiFi
 
컨테이너 기술 소개 - Warden, Garden, Docker
컨테이너 기술 소개 - Warden, Garden, Docker컨테이너 기술 소개 - Warden, Garden, Docker
컨테이너 기술 소개 - Warden, Garden, Docker
 
The First Mile - Edge and IoT Data Collection With Apache Nifi and MiniFi
The First Mile - Edge and IoT Data Collection With Apache Nifi and MiniFiThe First Mile - Edge and IoT Data Collection With Apache Nifi and MiniFi
The First Mile - Edge and IoT Data Collection With Apache Nifi and MiniFi
 
Ext osad initial-eval-march2015
Ext osad initial-eval-march2015Ext osad initial-eval-march2015
Ext osad initial-eval-march2015
 
Apache Geode Meetup, London
Apache Geode Meetup, LondonApache Geode Meetup, London
Apache Geode Meetup, London
 
Build software like a bag of marbles, not a castle of LEGO®
Build software like a bag of marbles, not a castle of LEGO®Build software like a bag of marbles, not a castle of LEGO®
Build software like a bag of marbles, not a castle of LEGO®
 
BYOP: Custom Processor Development with Apache NiFi
BYOP: Custom Processor Development with Apache NiFiBYOP: Custom Processor Development with Apache NiFi
BYOP: Custom Processor Development with Apache NiFi
 
How we use Twisted in Launchpad
How we use Twisted in LaunchpadHow we use Twisted in Launchpad
How we use Twisted in Launchpad
 
2.0 Client Libraries & Using the Java Client by Noah Crowley, Developer Advoc...
2.0 Client Libraries & Using the Java Client by Noah Crowley, Developer Advoc...2.0 Client Libraries & Using the Java Client by Noah Crowley, Developer Advoc...
2.0 Client Libraries & Using the Java Client by Noah Crowley, Developer Advoc...
 
Using the Java Client Library by Noah Crowley, DevRel | InfluxData
Using the Java Client Library by Noah Crowley, DevRel | InfluxDataUsing the Java Client Library by Noah Crowley, DevRel | InfluxData
Using the Java Client Library by Noah Crowley, DevRel | InfluxData
 
Road to NODES - Handling Neo4j Data with Apache Hop
Road to NODES - Handling Neo4j Data with Apache HopRoad to NODES - Handling Neo4j Data with Apache Hop
Road to NODES - Handling Neo4j Data with Apache Hop
 
Social Connections 2015 CrossWorlds and Domino
Social Connections 2015 CrossWorlds and DominoSocial Connections 2015 CrossWorlds and Domino
Social Connections 2015 CrossWorlds and Domino
 

Más de elliando dias

Why you should be excited about ClojureScript
Why you should be excited about ClojureScriptWhy you should be excited about ClojureScript
Why you should be excited about ClojureScriptelliando dias
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structureselliando dias
 
Nomenclatura e peças de container
Nomenclatura  e peças de containerNomenclatura  e peças de container
Nomenclatura e peças de containerelliando dias
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agilityelliando dias
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Librarieselliando dias
 
How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!elliando dias
 
A Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the WebA Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the Webelliando dias
 
Introdução ao Arduino
Introdução ao ArduinoIntrodução ao Arduino
Introdução ao Arduinoelliando dias
 
Incanter Data Sorcery
Incanter Data SorceryIncanter Data Sorcery
Incanter Data Sorceryelliando dias
 
Fab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine DesignFab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine Designelliando dias
 
The Digital Revolution: Machines that makes
The Digital Revolution: Machines that makesThe Digital Revolution: Machines that makes
The Digital Revolution: Machines that makeselliando dias
 
Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.elliando dias
 
Hadoop and Hive Development at Facebook
Hadoop and Hive Development at FacebookHadoop and Hive Development at Facebook
Hadoop and Hive Development at Facebookelliando dias
 
Multi-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case StudyMulti-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case Studyelliando dias
 
From Lisp to Clojure/Incanter and RAn Introduction
From Lisp to Clojure/Incanter and RAn IntroductionFrom Lisp to Clojure/Incanter and RAn Introduction
From Lisp to Clojure/Incanter and RAn Introductionelliando dias
 

Más de elliando dias (20)

Why you should be excited about ClojureScript
Why you should be excited about ClojureScriptWhy you should be excited about ClojureScript
Why you should be excited about ClojureScript
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structures
 
Nomenclatura e peças de container
Nomenclatura  e peças de containerNomenclatura  e peças de container
Nomenclatura e peças de container
 
Geometria Projetiva
Geometria ProjetivaGeometria Projetiva
Geometria Projetiva
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agility
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Libraries
 
How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!
 
Ragel talk
Ragel talkRagel talk
Ragel talk
 
A Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the WebA Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the Web
 
Introdução ao Arduino
Introdução ao ArduinoIntrodução ao Arduino
Introdução ao Arduino
 
Minicurso arduino
Minicurso arduinoMinicurso arduino
Minicurso arduino
 
Incanter Data Sorcery
Incanter Data SorceryIncanter Data Sorcery
Incanter Data Sorcery
 
Rango
RangoRango
Rango
 
Fab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine DesignFab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine Design
 
The Digital Revolution: Machines that makes
The Digital Revolution: Machines that makesThe Digital Revolution: Machines that makes
The Digital Revolution: Machines that makes
 
Hadoop + Clojure
Hadoop + ClojureHadoop + Clojure
Hadoop + Clojure
 
Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.
 
Hadoop and Hive Development at Facebook
Hadoop and Hive Development at FacebookHadoop and Hive Development at Facebook
Hadoop and Hive Development at Facebook
 
Multi-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case StudyMulti-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case Study
 
From Lisp to Clojure/Incanter and RAn Introduction
From Lisp to Clojure/Incanter and RAn IntroductionFrom Lisp to Clojure/Incanter and RAn Introduction
From Lisp to Clojure/Incanter and RAn Introduction
 

Último

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 

Último (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 

Building High Performance Scalable TCP/IP Servers with Apache MINA

  • 1. Building High Performance Scalable TCP/IP Servers with Apache MINA Originally presented at ApacheCon Europe 2006 in Dublin Latest slides and code samples at http://people.apache.org/~proyal Presented by Peter Royal, <proyal@apache.org> 1
  • 2. Goals of this presentation •Introduction to MINA •Demonstration of what it can do •Converting blocking-IO code to MINA •Hopefully inspire you to use it :) 2
  • 3. What is MINA •Multipurpose Infrastructure for Networked Applications •A framework (the F word!) for building networked clients and servers based on non-blocking IO •http://directory.apache.org/subprojects/mina/ 3
  • 4. Brief history of MINA •Started out as Netty2 from Trustin Lee •Joined the Directory Project as the SEDA-based directory needed an asynchronous I/O layer. 4
  • 5. IoHandler IoFilter Inbound IoFilter Outbound IoFilter IoProcessor IoAcceptor Network Architectural overview 5
  • 6. IoSession •Holder of state for a connection (either client-side or server-side) •Passed along with every event •Important Methods •write •close •get/setAttribute 6
  • 7. IoHandler •Akin to a Servlet IoHandler •Endpoint of a filter chain IoFilter •Important Methods IoFilter •sessionOpened IoFilter •messageReceived IoProcessor •sessionClosed IoAcceptor 7
  • 8. IoFilterChain •Chain of IoFilter's for each IoSession •Can setup template chains per IoConnector/IoAcceptor •Dynamic addition/removal 8
  • 9. IoFilters •Akin to a ServletFilter IoHandler •View/Hack/Slash the event stream IoFilter •Important Methods IoFilter •sessionOpened IoFilter •messageReceived IoProcessor •filterWrite IoAcceptor •sessionClosed 9
  • 10. IoAcceptor •Server-side entry point. IoHandler •Accepts incoming connections and fires IoFilter events to an IoHandler •Important Methods IoFilter •bind IoFilter IoProcessor IoAcceptor 10
  • 11. IoConnector •Client-side entry point •Initiate connections to a remote service, and fires events to an IoHandler •Important Methods •connect 11
  • 12. IoProcessor •Internal component IoHandler •Handles reading and writing data to an IoFilter underlying connection •Each connection is associated with a IoFilter single IoProcessor (shared amongst IoFilter multiple connections) IoProcessor IoAcceptor 12
  • 13. Our Sample Application •Persistent connections from clients •Serialize java objects across the wire •Clients connect and are given a unit of work, which in this case, is just an instruction for how long to wait until getting their next instruction. 13
  • 14. Monitoring Performance •Thread activity via jconsole •CPU Activity via Activity Monitor •(or your favorite tool) 14
  • 16. Scalability •JVM limit on number of threads •The lovely java.lang.OutOfMemoryError: unable to create new native thread 16
  • 17. Lets convert to MINA! •Server side first •(Client to come soon) 17
  • 19. New Limitations? •Java Serialization takes up CPU time •(a profiler would reveal this) •OS limit of per-process open files •(consult the documentation for your OS) •sysctl / ulimit to view/change on unix-like systems 19
  • 20. MINA on the client •Since we will be using MINA's built-in support for building protocols, the ProtocolCodecFilter •Any socket client can talk to MINA •We’re using MINA on both sides for simplicity in our examples. 20
  • 21. Client is just like the server •IoHandler and IoFilter's •Can re-use filters on both client and server sides. 21
  • 24. Filters that ship today •Logging •Compression •Blacklist •SSL •Requires Java 5 24
  • 25. Filters we are working on •Traffic Shaping •Rate Limiting •Performance Monitoring 25
  • 26. Some things built on MINA •LDAP - Apache DS <http://directory.apache.org/ subprojects/apacheds/index.html> •Flash - red5 <http://www.osflash.org/red5> •HTTP - AsyncWeb <http://asyncweb.safehaus.org/> 26
  • 27. Performance Tips •Set the number of IoProcessor’s to be equal to the number of CPU cores. •Benchmark! Users have found both heap and direct buffers, pooled and not pooled, to be beneficial depending on their workloads. •For ultra-low latency with small message sizes on a local lan, disable Nagle’s algorithm; the TCP_NODELAY flag. 27