You are on page 1of 28

Introduction to MINA

Trustin Lee
NHN Corporation

trustin@apache.org
http://people.apache.org/~trustin
Agenda
• Overview
• In-depth View
• Demonstration
• Future
• Conclusion

2
Agenda: Overview
• Overview
• What is MINA?
• Advantages
• References
• In-depth View
• Demonstration
• Future
• Conclusion

3
Overview

What is MINA?

A Multi-purpose
Infrastructure
for Network
Applications

4
Overview

What is MINA?
• Network application framework for Java
• Abstract API
• Event-driven
• Asynchronous
• Implementations
• NIO Socket & Datagram
• <Your favorite transport>

5
Overview

Advantages: Productivity
• Unit test friendly
• Abstract API + mock objects
• Extensible
• Runtime modification of application behavior
using ‘filters’
• Maintainable and Reusable
• Separation of networking code (MINA),
protocol codec, and business logic

6
Overview

Advantages: Performance
• AMQP Test
• Client and server
• 4 dual-core Opterons
• Via Gigabits Ethernet
• 10 clients
• Payload: 256+ bytes (excl. AMQP headers)
• Avg : 180,000 msg/sec
• Max: 220,000 msg/sec
Courtesy of Robert J. Greig, JP Morgan Chase & Co.

7
Overview

Advantages: Stability
• API design
• Running toward 1.0 fast
• Implementation
• We’ve been doing this since 2004

8
Overview

Who Uses MINA?


• The Apache Directory Project
• LDAPv3 • Kerberos • DNS
• ChangePW • DHCP • NTP

• XFire + AsyncWeb SOAP over HTTP

• AMQP Advanced Message Queuing Protocol

• QuickFIX/J Financial Information eXchange

• RED5 Server Macromedia Flash Media RTMP

9
Overview

Who Uses MINA?


• ObjectRADIUS RADIUS

• FreeCast P2P media streaming

• JStyx A NFS-like file sharing protocol

• Proprietary projects
• XMPP (Jabber · GTalk) implementation
• SMS · MMS Gateways
• And many more!

10
Agenda: In-depth View
• Overview
• In-depth View
• At a Glance
• Core Constructs
• In-VM Pipe
• Demonstration
• Future
• Conclusion

11
In-depth

At a GlanceLegend
Remote Peer Core
Extension Point

Low-level

Low-level
I/O Protocol Implementation

I/O
IoService
Filtered I/O
Performs Actual I/O
I/O Event

Request

IoFilterChain
IoFilter #1
IoFilter #2 Filters Events & Requests
IoFilter #3
Filtered I/O

Request
Event

I/O

A Connection
IoSession
IoHandler <Your Protocol Logic>
12
In-depth

IoService
IoSessionManager
IoService
Server-side: Client-side:
Accepts clients Connects to a server

IoAcceptor IoConnector

And their
nio::SocketAcceptor nio::SocketConnector
implementations
nio::DatagramAcceptor nio::DatagramConnector

v mpipe::VmPipeAcceptor v mpipe::VmPipeConnector

13
In-depth

IoFilter
• An event & request interceptor
• Reusable
• Hot-deployable
• SSL · TLS • Logger
• Thread pool • Overload detector
• Performance profiler • Traffic shaper
• Lightweight firewall • Authorization

14
In-depth

ThreadPoolFilter
No thread pool: single thread setting for minimal latency

IoAcceptor IoHandler

One thread pool: general setting for high throughput

Thread
IoAcceptor Pool IoHandler
Filter

More than one thread pool: special setting for CPU-intensive jobs
CPU-
Thread Thread
intensive
IoAcceptor Pool Pool IoHandler
jobs
Filter Filter
(IoFilter)

15
In-depth

ProtocolCodecFilter
• Clear separation and reusability

• Business logic – IoHandler


• Protocol codec – ProtocolCodecFilter
• Object serialization
• Text line

16
In-depth

ProtocolCodecFilter Legend
Remote Peer Core
Extension Point

Low-level

Low-level
Protocol Implementation

I/O

I/O
IoService

Filtered I/O
I/O Event

Request
P
E ro
to
IoFilterChain
n
co co POJO → ByteB
d l
Encode
e
r C
o uffer
ProtocolCodecFilter d
D e
e c
Decode co F
a ByteBuffer
d ct
e
r o
ry → POJO
Filtered I/O

Request
Event

I/O

IoSession
IoHandler → Business Logic Only!
17
In-depth

In-VM Pipe
I/O events are converted into

‘Direct Method Invocations’


 No protocol codec
 No network latency
 Using the same API

18
Agenda: Demonstration
• Overview
• In-depth View
• Demonstration
• Future
• Conclusion

19
Example

Reverse Echo Server


• Echo server which reverses a line
• Using a built-in text line protocol
codec in MINA

20
Agenda: Future
• Overview
• In-depth View
• Demonstration
• Future
• MINA as a Platform
• Real-time Management
• Participation
• Conclusion

21
Future

MINA as a Platform
Real-Time
Integration Management
with Apache System
ASN.1 for complex protocols
Users can build customized
Rapidly Design custom
servers
HTTP FTP Prototyped
with Kerberos
ready-made protocol
protocols
codecs.
just like
Protocol
drawing a UML!
Visual Protocol
SMTP …… Designer LDAP
(ASN.1-based)

Popular ASN.1
Others
Protocols Codec

MINA Core Library


22
Future

Real-Time Management System


• A universal management view
• JMX console and Web browser
• Real time access
• Server traffic
• IoFilter Hot-deployment
• Which client is sending what message now?
• Which message takes too long to process?
• And <what you want to monitor>

23
Future

We Need Your Participation!


• Sounds exciting?
• Your feedback is our blood!
• Ask questions
• Criticize design flaws
• Report bugs
• Publish performance test results

24
Agenda: Conclusion
• Overview
• In-depth View
• Demonstration
• Future
• Conclusion

25
Conclusion

Conclusion
• MINA is…
• A network application framework for…
• Productivity
• Performance
• Stability
• MINA will be…
• Full-featured dev. & mgmt. platform for
network applications

26
Resources
• Homepage
• http://directory.apache.org/subprojects/mina/
• More useful examples

• Mailing List
• mina-dev@directory.apache.org

27
Thank You!
Q&A

You might also like