SlideShare uma empresa Scribd logo
1 de 83
Baixar para ler offline
(if you can’t read this, move closer!)




                          Apache
                     The high-performance protocol construction toolkit.




                               Peter Royal <proyal@apache.org>
                               Originally presented at ApacheCon US 2007 in
                                                 Atlanta, GA




Wednesday, November 14, 2007                                                  1
Hi, I’m Peter
                                http://fotap.org/~osi

Wednesday, November 14, 2007                            2
MINA hacker since
                         Fall 2005


Wednesday, November 14, 2007              3
Radar Networks
                               http://radarnetworks.com

Wednesday, November 14, 2007                              4
San Francisco
Wednesday, November 14, 2007                   5
Apache Member
                                  http://apache.org

Wednesday, November 14, 2007                          6
What is MINA?



Wednesday, November 14, 2007                   7
MINA?
Wednesday, November 14, 2007           8
Multipurpose
                   Infrastructure
                   Networked
                   Applications
                               http://mina.apache.org
Wednesday, November 14, 2007                            9
Built on Java NIO



Wednesday, November 14, 2007                  10
Non-Blocking



Wednesday, November 14, 2007                  11
Asynchronous



Wednesday, November 14, 2007                  12
Event-Driven
                                   (SEDA!)




Wednesday, November 14, 2007                  13
Multiple Transports
                               (framework is really agnostic)




Wednesday, November 14, 2007                                    14
TCP



Wednesday, November 14, 2007         15
UDP
                               (being re-written for 2.0)




Wednesday, November 14, 2007                                16
In-VM
                               (great for testing)




Wednesday, November 14, 2007                         17
Apache Portable
                           Runtime (APR)
                               (under development, alternate
                                 TCP/UDP implementation)




Wednesday, November 14, 2007                                   18
(and more..)



Wednesday, November 14, 2007                  19
Smartly Designed



Wednesday, November 14, 2007                 20
Follows Inversion of
                      Control Pattern
                      (plays nicely with PicoContainer, Spring, etc)




Wednesday, November 14, 2007                                           21
Separation of Concerns



Wednesday, November 14, 2007          22
Wire
                                Protocol
                               Application
                                  Logic



                         Rather than this...
Wednesday, November 14, 2007                   23
Wire     Application
                     Protocol     Logic




            Concerns are Separated
Wednesday, November 14, 2007                  24
Stable and Production-
                        Ready
              • v1.0 released Fall 2006
              • v1.1 released April 2007
                  •     Same API as v1.0 but uses Java 5 Concurrency primitives

              • v2.0 this year
                  •     API simplification based on lessons learned

                  •     Performance boosts too!




Wednesday, November 14, 2007                                                      25
Many Protocols & Users
                               (here are a few...)




Wednesday, November 14, 2007                         26
Apache
                Directory
           http://directory.apache.org

       LDAPv3, NTP, DNS, DHCP and
                Kerberos




Wednesday, November 14, 2007             27
SubEthaSTMP
         http://subethasmtp.tigris.org/

                               SMTP




Wednesday, November 14, 2007              28
Apache
               (incubating)
                   Qpid
          http://cwiki.apache.org/qpid/

        Advanced Messaging Queuing
             Protocol (AMQP)

                 (from Wall Street!)




Wednesday, November 14, 2007              29
Openfire
         http://www.jivesoftware.com/
               products/openfire/

                               XMPP




Wednesday, November 14, 2007            30
red5
          http://www.osflash.org/red5

                        RTMP
                (talk to Flash player)




Wednesday, November 14, 2007             31
...and more!
                               (maybe you, next time!)




Wednesday, November 14, 2007                             32
Key Concepts



Wednesday, November 14, 2007                  33
ByteBuffer
              • Core NIO construct
              • MINA version that wraps and provides
                    additional convenience methods
                  •     auto-expanding, string encoding

              • MINA gives control...
                  •     allocate from the Heap or Stack

                  •     optional Pooling
                       •       (in v2, will be non-pooled and heap-only, as it provides the best
                               performance)


Wednesday, November 14, 2007                                                                       34
Future
              • Represents a function call that completes
                    asynchronously
              • Provides blocking functions to retrieve the
                    result
              • MINA allows callbacks to be invoked upon
                    completion, so invoking thread can “fire and
                    forget”
                  •     (unlike the Java 5 Future)



Wednesday, November 14, 2007                                      35
36




         IoHandler
Writes




           IoFilter
           IoFilter
           IoFilter
                       Reads
         IoProcessor
          IoService




                               Wednesday, November 14, 2007
Writes




                                            IoProcessor




                                                                                             IoHandler
                                IoService




                                                          IoFilter



                                                                     IoFilter


                                                                                  IoFilter
                                             Reads


                               Two Versions

Wednesday, November 14, 2007                                                                             37
Writes




                                                IoProcessor




                                                                                                 IoHandler
                                    IoService




                                                              IoFilter



                                                                         IoFilter


                                                                                      IoFilter
                                                 Reads


                                  IoAcceptor
                                         “act as server”
                               single thread for new connections

Wednesday, November 14, 2007                                                                                 38
Writes




                                             IoProcessor




                                                                                              IoHandler
                                IoService




                                                           IoFilter



                                                                      IoFilter


                                                                                   IoFilter
                                              Reads


                               IoConnector
                                            “act as client”

Wednesday, November 14, 2007                                                                              39
Writes




                                           IoProcessor




                                                                                            IoHandler
                               IoService




                                                         IoFilter



                                                                    IoFilter


                                                                                 IoFilter
                                            Reads


                   Connection instance
                     is an IoSession
Wednesday, November 14, 2007                                                                            40
Writes




                                           IoProcessor




                                                                                            IoHandler
                               IoService




                                                         IoFilter



                                                                    IoFilter


                                                                                 IoFilter
                                            Reads


          Handles reads and writes

Wednesday, November 14, 2007                                                                            41
Writes




                                           IoProcessor




                                                                                            IoHandler
                               IoService




                                                         IoFilter



                                                                    IoFilter


                                                                                 IoFilter
                                            Reads


                  Instance count scales
                     with CPU/Load
Wednesday, November 14, 2007                                                                            42
Writes




                                           IoProcessor




                                                                                            IoHandler
                               IoService




                                                         IoFilter



                                                                    IoFilter


                                                                                 IoFilter
                                            Reads


     Session fixed to an Instance
                                  (under review for v2)

Wednesday, November 14, 2007                                                                            43
Writes




                                           IoProcessor




                                                                                            IoHandler
                               IoService




                                                         IoFilter



                                                                    IoFilter


                                                                                 IoFilter
                                            Reads


                         Chain of IoFilter’s

Wednesday, November 14, 2007                                                                            44
Writes




                                             IoProcessor




                                                                                              IoHandler
                                 IoService




                                                           IoFilter



                                                                      IoFilter


                                                                                   IoFilter
                                              Reads


                               Per Connection

Wednesday, November 14, 2007                                                                              45
46




         IoHandler
Writes




           IoFilter
           IoFilter
                               Reusable
           IoFilter
                       Reads
         IoProcessor
          IoService




                                          Wednesday, November 14, 2007
Writes




                                             IoProcessor




                                                                                              IoHandler
                                 IoService




                                                           IoFilter



                                                                      IoFilter


                                                                                   IoFilter
                                              Reads


                               Hot Deployable

Wednesday, November 14, 2007                                                                              47
Writes




                                             IoProcessor




                                                                                              IoHandler
                                 IoService




                                                           IoFilter



                                                                      IoFilter


                                                                                   IoFilter
                                              Reads


                               Filter all events
                                 Read / Write / Idle / etc

Wednesday, November 14, 2007                                                                              48
Writes




                                           IoProcessor




                                                                                            IoHandler
                               IoService




                                                         IoFilter



                                                                    IoFilter


                                                                                 IoFilter
                                            Reads


                          Application Logic
                            Lives Here
Wednesday, November 14, 2007                                                                            49
Large Library of
                                  IoFilter’s


Wednesday, November 14, 2007                      50
Protocol Conversion

              • Framework to plug in your own codecs to
                    handle conversion to/from a ByteBuffer
              • Existing codecs
                  •     Text-based

                  •     Java Serialization




Wednesday, November 14, 2007                                 51
Blacklist



Wednesday, November 14, 2007               52
Logging
                               (great for debugging!)




Wednesday, November 14, 2007                            53
SSL / TLS



Wednesday, November 14, 2007               54
Compression



Wednesday, November 14, 2007                 55
Read Throttling
                                 (write throttling is in 2.0)




Wednesday, November 14, 2007                                    56
Thread Models
                                  (a necessary evil)




Wednesday, November 14, 2007                           57
“single threaded”



Wednesday, November 14, 2007                  58
One IoProcessor
                              Thread


Wednesday, November 14, 2007                59
Scalability sucks



Wednesday, November 14, 2007                       60
Add more IoProcessor
                    Threads
                               (at least one per CPU core)




Wednesday, November 14, 2007                                 61
Lowest latency
                                Scales nicely
                       (connection latency to be addressed in v2)




Wednesday, November 14, 2007                                        62
“multi threaded”



Wednesday, November 14, 2007                  63
use ExecutorFilter



Wednesday, November 14, 2007                 64
IoProcessor threads
               only do reads & writes
                               (the intent)




Wednesday, November 14, 2007                  65
Filters execute on a
                       different thread.
                               (filter location is key!)




Wednesday, November 14, 2007                              66
Work for a session is
                      serialized
                               (queued per session)




Wednesday, November 14, 2007                          67
Work is delegated to an
                  Executor
              (generally a java.util.concurrent.ThreadPoolExecutor)




Wednesday, November 14, 2007                                          68
Size thread pool to
                “active” session count
                               (too much in queue == OOM!
                                Use the Read Throttle filter)




Wednesday, November 14, 2007                                   69
“recommended
                      application pattern”
              • use ExecutorFilter as first in chain
                  •     unless you need really low latency

              • use ProtocolCodecFilter
                  •     convert the wire protocol into a Java representation

              • put application logic into an IoHandler
              • store state in the IoSession
              • minimum of Java 5
                  •     java.util.concurrent rocks!
Wednesday, November 14, 2007                                                   70
Example Time!



Wednesday, November 14, 2007                   71
Everybody loves a Haiku



Wednesday, November 14, 2007         72
This is our Haiku validator
Wednesday, November 14, 2007         73
Simple Protocol

              • Connect
              • Send 3 lines of text
              • Receive HAIKU! or NOT A HAIKU:
                  •     (plus a little reason why not)




Wednesday, November 14, 2007                             74
ProtocolCodecFilter +
               TextLineCodecFactory
                               Bytes to Java String’s. For free!




Wednesday, November 14, 2007                                       75
ToHaikuIoFilter
                                 Three String’s to a Haiku
Wednesday, November 14, 2007                                 76
Filter is very testable
                               (mock objects rock!)
Wednesday, November 14, 2007                          77
IoHandler is very simple
                               Validate Haiku, send result
Wednesday, November 14, 2007                                 78
Also very testable
Wednesday, November 14, 2007                  79
Very easy to hook it all up
Wednesday, November 14, 2007          80
Questions?
                                (I’m here all week!)
Wednesday, November 14, 2007                           81
Thank You!
Wednesday, November 14, 2007                82
http://mina.apache.org



Wednesday, November 14, 2007             83

Mais conteúdo relacionado

Destaque

Building High Performance Scalable TCP/IP Servers with Apache MINA
Building High Performance Scalable TCP/IP Servers with Apache MINABuilding High Performance Scalable TCP/IP Servers with Apache MINA
Building High Performance Scalable TCP/IP Servers with Apache MINAelliando dias
 
Apache Mina
Apache MinaApache Mina
Apache Minalake xie
 
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
 
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
 

Destaque (7)

Building High Performance Scalable TCP/IP Servers with Apache MINA
Building High Performance Scalable TCP/IP Servers with Apache MINABuilding High Performance Scalable TCP/IP Servers with Apache MINA
Building High Performance Scalable TCP/IP Servers with Apache MINA
 
Introduction to Apache MINA
Introduction to Apache MINAIntroduction to Apache MINA
Introduction to Apache MINA
 
Mina2
Mina2Mina2
Mina2
 
Apache Mina
Apache MinaApache Mina
Apache Mina
 
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
 
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
 

Semelhante a Apache MINA: The high-performance protocol construction toolkit.

Using Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRBUsing Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRBHiro Asari
 
JBoss AS 7 from a user perspective
JBoss AS 7 from a user perspectiveJBoss AS 7 from a user perspective
JBoss AS 7 from a user perspectiveMax Andersen
 
TorqueBox - Ultrapassando a fronteira entre Java e Ruby
TorqueBox - Ultrapassando a fronteira entre Java e RubyTorqueBox - Ultrapassando a fronteira entre Java e Ruby
TorqueBox - Ultrapassando a fronteira entre Java e RubyBruno Oliveira
 
Conquistando el Servidor con Node.JS
Conquistando el Servidor con Node.JSConquistando el Servidor con Node.JS
Conquistando el Servidor con Node.JSCaridy Patino
 
TorqueBox - When Java meets Ruby
TorqueBox - When Java meets RubyTorqueBox - When Java meets Ruby
TorqueBox - When Java meets RubyBruno Oliveira
 
Play concurrency
Play concurrencyPlay concurrency
Play concurrencyJustin Long
 
Parallelizing a Real-Time Steering Simulation for Computer Games with OpenMP ...
Parallelizing a Real-Time Steering Simulation for Computer Games with OpenMP ...Parallelizing a Real-Time Steering Simulation for Computer Games with OpenMP ...
Parallelizing a Real-Time Steering Simulation for Computer Games with OpenMP ...Bjoern Knafla
 
Empowering the Social Web with Apache Shindig
Empowering the Social Web with Apache ShindigEmpowering the Social Web with Apache Shindig
Empowering the Social Web with Apache Shindigplindner
 

Semelhante a Apache MINA: The high-performance protocol construction toolkit. (13)

Using Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRBUsing Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRB
 
JBoss AS 7 from a user perspective
JBoss AS 7 from a user perspectiveJBoss AS 7 from a user perspective
JBoss AS 7 from a user perspective
 
TorqueBox - Ultrapassando a fronteira entre Java e Ruby
TorqueBox - Ultrapassando a fronteira entre Java e RubyTorqueBox - Ultrapassando a fronteira entre Java e Ruby
TorqueBox - Ultrapassando a fronteira entre Java e Ruby
 
Caridy patino - node-js
Caridy patino - node-jsCaridy patino - node-js
Caridy patino - node-js
 
Conquistando el Servidor con Node.JS
Conquistando el Servidor con Node.JSConquistando el Servidor con Node.JS
Conquistando el Servidor con Node.JS
 
CommonJS Frameworks
CommonJS FrameworksCommonJS Frameworks
CommonJS Frameworks
 
TorqueBox - When Java meets Ruby
TorqueBox - When Java meets RubyTorqueBox - When Java meets Ruby
TorqueBox - When Java meets Ruby
 
Play concurrency
Play concurrencyPlay concurrency
Play concurrency
 
RubyConf 2009
RubyConf 2009RubyConf 2009
RubyConf 2009
 
Parallelizing a Real-Time Steering Simulation for Computer Games with OpenMP ...
Parallelizing a Real-Time Steering Simulation for Computer Games with OpenMP ...Parallelizing a Real-Time Steering Simulation for Computer Games with OpenMP ...
Parallelizing a Real-Time Steering Simulation for Computer Games with OpenMP ...
 
Play 2 pip
Play 2 pipPlay 2 pip
Play 2 pip
 
Introducing Java 7
Introducing Java 7Introducing Java 7
Introducing Java 7
 
Empowering the Social Web with Apache Shindig
Empowering the Social Web with Apache ShindigEmpowering the Social Web with Apache Shindig
Empowering the Social Web with Apache Shindig
 

Último

Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsAndrey Dotsenko
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 

Último (20)

Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 

Apache MINA: The high-performance protocol construction toolkit.

  • 1. (if you can’t read this, move closer!) Apache The high-performance protocol construction toolkit. Peter Royal <proyal@apache.org> Originally presented at ApacheCon US 2007 in Atlanta, GA Wednesday, November 14, 2007 1
  • 2. Hi, I’m Peter http://fotap.org/~osi Wednesday, November 14, 2007 2
  • 3. MINA hacker since Fall 2005 Wednesday, November 14, 2007 3
  • 4. Radar Networks http://radarnetworks.com Wednesday, November 14, 2007 4
  • 6. Apache Member http://apache.org Wednesday, November 14, 2007 6
  • 7. What is MINA? Wednesday, November 14, 2007 7
  • 9. Multipurpose Infrastructure Networked Applications http://mina.apache.org Wednesday, November 14, 2007 9
  • 10. Built on Java NIO Wednesday, November 14, 2007 10
  • 13. Event-Driven (SEDA!) Wednesday, November 14, 2007 13
  • 14. Multiple Transports (framework is really agnostic) Wednesday, November 14, 2007 14
  • 16. UDP (being re-written for 2.0) Wednesday, November 14, 2007 16
  • 17. In-VM (great for testing) Wednesday, November 14, 2007 17
  • 18. Apache Portable Runtime (APR) (under development, alternate TCP/UDP implementation) Wednesday, November 14, 2007 18
  • 21. Follows Inversion of Control Pattern (plays nicely with PicoContainer, Spring, etc) Wednesday, November 14, 2007 21
  • 22. Separation of Concerns Wednesday, November 14, 2007 22
  • 23. Wire Protocol Application Logic Rather than this... Wednesday, November 14, 2007 23
  • 24. Wire Application Protocol Logic Concerns are Separated Wednesday, November 14, 2007 24
  • 25. Stable and Production- Ready • v1.0 released Fall 2006 • v1.1 released April 2007 • Same API as v1.0 but uses Java 5 Concurrency primitives • v2.0 this year • API simplification based on lessons learned • Performance boosts too! Wednesday, November 14, 2007 25
  • 26. Many Protocols & Users (here are a few...) Wednesday, November 14, 2007 26
  • 27. Apache Directory http://directory.apache.org LDAPv3, NTP, DNS, DHCP and Kerberos Wednesday, November 14, 2007 27
  • 28. SubEthaSTMP http://subethasmtp.tigris.org/ SMTP Wednesday, November 14, 2007 28
  • 29. Apache (incubating) Qpid http://cwiki.apache.org/qpid/ Advanced Messaging Queuing Protocol (AMQP) (from Wall Street!) Wednesday, November 14, 2007 29
  • 30. Openfire http://www.jivesoftware.com/ products/openfire/ XMPP Wednesday, November 14, 2007 30
  • 31. red5 http://www.osflash.org/red5 RTMP (talk to Flash player) Wednesday, November 14, 2007 31
  • 32. ...and more! (maybe you, next time!) Wednesday, November 14, 2007 32
  • 34. ByteBuffer • Core NIO construct • MINA version that wraps and provides additional convenience methods • auto-expanding, string encoding • MINA gives control... • allocate from the Heap or Stack • optional Pooling • (in v2, will be non-pooled and heap-only, as it provides the best performance) Wednesday, November 14, 2007 34
  • 35. Future • Represents a function call that completes asynchronously • Provides blocking functions to retrieve the result • MINA allows callbacks to be invoked upon completion, so invoking thread can “fire and forget” • (unlike the Java 5 Future) Wednesday, November 14, 2007 35
  • 36. 36 IoHandler Writes IoFilter IoFilter IoFilter Reads IoProcessor IoService Wednesday, November 14, 2007
  • 37. Writes IoProcessor IoHandler IoService IoFilter IoFilter IoFilter Reads Two Versions Wednesday, November 14, 2007 37
  • 38. Writes IoProcessor IoHandler IoService IoFilter IoFilter IoFilter Reads IoAcceptor “act as server” single thread for new connections Wednesday, November 14, 2007 38
  • 39. Writes IoProcessor IoHandler IoService IoFilter IoFilter IoFilter Reads IoConnector “act as client” Wednesday, November 14, 2007 39
  • 40. Writes IoProcessor IoHandler IoService IoFilter IoFilter IoFilter Reads Connection instance is an IoSession Wednesday, November 14, 2007 40
  • 41. Writes IoProcessor IoHandler IoService IoFilter IoFilter IoFilter Reads Handles reads and writes Wednesday, November 14, 2007 41
  • 42. Writes IoProcessor IoHandler IoService IoFilter IoFilter IoFilter Reads Instance count scales with CPU/Load Wednesday, November 14, 2007 42
  • 43. Writes IoProcessor IoHandler IoService IoFilter IoFilter IoFilter Reads Session fixed to an Instance (under review for v2) Wednesday, November 14, 2007 43
  • 44. Writes IoProcessor IoHandler IoService IoFilter IoFilter IoFilter Reads Chain of IoFilter’s Wednesday, November 14, 2007 44
  • 45. Writes IoProcessor IoHandler IoService IoFilter IoFilter IoFilter Reads Per Connection Wednesday, November 14, 2007 45
  • 46. 46 IoHandler Writes IoFilter IoFilter Reusable IoFilter Reads IoProcessor IoService Wednesday, November 14, 2007
  • 47. Writes IoProcessor IoHandler IoService IoFilter IoFilter IoFilter Reads Hot Deployable Wednesday, November 14, 2007 47
  • 48. Writes IoProcessor IoHandler IoService IoFilter IoFilter IoFilter Reads Filter all events Read / Write / Idle / etc Wednesday, November 14, 2007 48
  • 49. Writes IoProcessor IoHandler IoService IoFilter IoFilter IoFilter Reads Application Logic Lives Here Wednesday, November 14, 2007 49
  • 50. Large Library of IoFilter’s Wednesday, November 14, 2007 50
  • 51. Protocol Conversion • Framework to plug in your own codecs to handle conversion to/from a ByteBuffer • Existing codecs • Text-based • Java Serialization Wednesday, November 14, 2007 51
  • 53. Logging (great for debugging!) Wednesday, November 14, 2007 53
  • 54. SSL / TLS Wednesday, November 14, 2007 54
  • 56. Read Throttling (write throttling is in 2.0) Wednesday, November 14, 2007 56
  • 57. Thread Models (a necessary evil) Wednesday, November 14, 2007 57
  • 59. One IoProcessor Thread Wednesday, November 14, 2007 59
  • 61. Add more IoProcessor Threads (at least one per CPU core) Wednesday, November 14, 2007 61
  • 62. Lowest latency Scales nicely (connection latency to be addressed in v2) Wednesday, November 14, 2007 62
  • 65. IoProcessor threads only do reads & writes (the intent) Wednesday, November 14, 2007 65
  • 66. Filters execute on a different thread. (filter location is key!) Wednesday, November 14, 2007 66
  • 67. Work for a session is serialized (queued per session) Wednesday, November 14, 2007 67
  • 68. Work is delegated to an Executor (generally a java.util.concurrent.ThreadPoolExecutor) Wednesday, November 14, 2007 68
  • 69. Size thread pool to “active” session count (too much in queue == OOM! Use the Read Throttle filter) Wednesday, November 14, 2007 69
  • 70. “recommended application pattern” • use ExecutorFilter as first in chain • unless you need really low latency • use ProtocolCodecFilter • convert the wire protocol into a Java representation • put application logic into an IoHandler • store state in the IoSession • minimum of Java 5 • java.util.concurrent rocks! Wednesday, November 14, 2007 70
  • 72. Everybody loves a Haiku Wednesday, November 14, 2007 72
  • 73. This is our Haiku validator Wednesday, November 14, 2007 73
  • 74. Simple Protocol • Connect • Send 3 lines of text • Receive HAIKU! or NOT A HAIKU: • (plus a little reason why not) Wednesday, November 14, 2007 74
  • 75. ProtocolCodecFilter + TextLineCodecFactory Bytes to Java String’s. For free! Wednesday, November 14, 2007 75
  • 76. ToHaikuIoFilter Three String’s to a Haiku Wednesday, November 14, 2007 76
  • 77. Filter is very testable (mock objects rock!) Wednesday, November 14, 2007 77
  • 78. IoHandler is very simple Validate Haiku, send result Wednesday, November 14, 2007 78
  • 79. Also very testable Wednesday, November 14, 2007 79
  • 80. Very easy to hook it all up Wednesday, November 14, 2007 80
  • 81. Questions? (I’m here all week!) Wednesday, November 14, 2007 81