introduction to mina - apache mina — apache...

28
Introduction to MINA Trustin Lee NHN Corporation [email protected] http://people.apache.org/~trustin

Upload: others

Post on 04-Jun-2020

20 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to MINA - Apache MINA — Apache MINAmina.apache.org/mina-project/resources/ACAsia2006.pdfIntegration with Apache ASN.1 for complex protocols Users can build customized

Introduction to MINA

Trustin LeeNHN Corporation

[email protected]

http://people.apache.org/~trustin

Page 2: Introduction to MINA - Apache MINA — Apache MINAmina.apache.org/mina-project/resources/ACAsia2006.pdfIntegration with Apache ASN.1 for complex protocols Users can build customized

2

Agenda

• Overview• In-depth View• Demonstration• Future• Conclusion

Page 3: Introduction to MINA - Apache MINA — Apache MINAmina.apache.org/mina-project/resources/ACAsia2006.pdfIntegration with Apache ASN.1 for complex protocols Users can build customized

3

Agenda: Overview

• Overview• What is MINA?• Advantages• References

• In-depth View• Demonstration• Future• Conclusion

Page 4: Introduction to MINA - Apache MINA — Apache MINAmina.apache.org/mina-project/resources/ACAsia2006.pdfIntegration with Apache ASN.1 for complex protocols Users can build customized

4

What is MINA?

A Multi-purpose Infrastructure

for Network Applications

Overview

Page 5: Introduction to MINA - Apache MINA — Apache MINAmina.apache.org/mina-project/resources/ACAsia2006.pdfIntegration with Apache ASN.1 for complex protocols Users can build customized

5

What is MINA?

• Network application framework for Java• Abstract API

• Event-driven• Asynchronous

• Implementations• NIO Socket & Datagram• <Your favorite transport>

Overview

Page 6: Introduction to MINA - Apache MINA — Apache MINAmina.apache.org/mina-project/resources/ACAsia2006.pdfIntegration with Apache ASN.1 for complex protocols Users can build customized

6

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

Overview

Page 7: Introduction to MINA - Apache MINA — Apache MINAmina.apache.org/mina-project/resources/ACAsia2006.pdfIntegration with Apache ASN.1 for complex protocols Users can build customized

7

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.

Overview

Page 8: Introduction to MINA - Apache MINA — Apache MINAmina.apache.org/mina-project/resources/ACAsia2006.pdfIntegration with Apache ASN.1 for complex protocols Users can build customized

8

Advantages: Stability

• API design• Running toward 1.0 fast

• Implementation• We’ve been doing this since 2004

Overview

Page 9: Introduction to MINA - Apache MINA — Apache MINAmina.apache.org/mina-project/resources/ACAsia2006.pdfIntegration with Apache ASN.1 for complex protocols Users can build customized

9

Who Uses MINA?

• The Apache Directory Project

• XFire + AsyncWeb SOAP over HTTP

• AMQP Advanced Message Queuing Protocol

• QuickFIX/J Financial Information eXchange

• RED5 Server Macromedia Flash Media RTMP

• Kerberos• DHCP

• DNS• NTP

• LDAPv3• ChangePW

Overview

Page 10: Introduction to MINA - Apache MINA — Apache MINAmina.apache.org/mina-project/resources/ACAsia2006.pdfIntegration with Apache ASN.1 for complex protocols Users can build customized

10

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!

Overview

Page 11: Introduction to MINA - Apache MINA — Apache MINAmina.apache.org/mina-project/resources/ACAsia2006.pdfIntegration with Apache ASN.1 for complex protocols Users can build customized

11

Agenda: In-depth View• Overview

• In-depth View• At a Glance• Core Constructs• In-VM Pipe

• Demonstration• Future• Conclusion

Page 12: Introduction to MINA - Apache MINA — Apache MINAmina.apache.org/mina-project/resources/ACAsia2006.pdfIntegration with Apache ASN.1 for complex protocols Users can build customized

12

At a GlanceIn-depth

Remote Peer

IoService

IoHandler

IoFilterChain

Core

Extension Point

Protocol Implementation

Legend

Filtered I/O

Event I/O

Re

ques

t

I/O Event

Filte

red

I/O

Re

ques

t

Low-level

I/O

Low

-leve

l I/

O

IoFilter #1

IoFilter #2

IoFilter #3

IoSession<Your Protocol Logic>

Filters Events & Requests

Performs Actual I/O

A Connection

Page 13: Introduction to MINA - Apache MINA — Apache MINAmina.apache.org/mina-project/resources/ACAsia2006.pdfIntegration with Apache ASN.1 for complex protocols Users can build customized

13

IoAcceptor IoConnector

nio::DatagramConnector

nio::SocketConnector

vmpipe::VmPipeAcceptor vmpipe::VmPipeConnector

nio::DatagramAcceptor

nio::SocketAcceptor

IoSessionManagerIoService

IoServiceIn-depth

Server-side:Accepts clients

Client-side:Connects to a server

And their implementations

Page 14: Introduction to MINA - Apache MINA — Apache MINAmina.apache.org/mina-project/resources/ACAsia2006.pdfIntegration with Apache ASN.1 for complex protocols Users can build customized

14

IoFilter

• An event & request interceptor• Reusable • Hot-deployable

• Logger• Overload detector• Traffic shaper• Authorization

• SSL · TLS• Thread pool• Performance profiler• Lightweight firewall

In-depth

Page 15: Introduction to MINA - Apache MINA — Apache MINAmina.apache.org/mina-project/resources/ACAsia2006.pdfIntegration with Apache ASN.1 for complex protocols Users can build customized

15

IoAcceptor IoHandler

No thread pool: single thread setting for minimal latency

ThreadPoolFilter

IoAcceptorThread

PoolFilter

CPU-intensive

jobs(IoFilter)

ThreadPoolFilter

IoHandler

More than one thread pool: special setting for CPU-intensive jobs

IoAcceptorThread

PoolFilter

IoHandler

One thread pool: general setting for high throughput

In-depth

Page 16: Introduction to MINA - Apache MINA — Apache MINAmina.apache.org/mina-project/resources/ACAsia2006.pdfIntegration with Apache ASN.1 for complex protocols Users can build customized

16

ProtocolCodecFilter

• Clear separation and reusability

• Business logic – IoHandler• Protocol codec – ProtocolCodecFilter

• Object serialization • Text line

In-depth

Page 17: Introduction to MINA - Apache MINA — Apache MINAmina.apache.org/mina-project/resources/ACAsia2006.pdfIntegration with Apache ASN.1 for complex protocols Users can build customized

17

ProtocolCodecFilterRemote Peer

IoService

IoHandler

IoFilterChain

Core

Extension Point

Protocol Implementation

Legend

Filtered I/O

Event I/O

Re

ques

t

I/O Event

Filte

red

I/O

Re

ques

t

Low-level

I/O

Low

-leve

l I/

O

IoSession

ProtocolCodecFilter

Protocol Codec Factory

EncoderD

ecoder

Encode

Decode

In-depth

POJO →ByteBuffer

ByteBuffer → POJO

→ Business Logic Only!

Page 18: Introduction to MINA - Apache MINA — Apache MINAmina.apache.org/mina-project/resources/ACAsia2006.pdfIntegration with Apache ASN.1 for complex protocols Users can build customized

18

In-VM Pipe

I/O events are converted into

‘Direct Method Invocations’

In-depth

No protocol codec No network latency Using the same API

Page 19: Introduction to MINA - Apache MINA — Apache MINAmina.apache.org/mina-project/resources/ACAsia2006.pdfIntegration with Apache ASN.1 for complex protocols Users can build customized

19

Agenda: Demonstration• Overview• In-depth View

• Demonstration• Future• Conclusion

Page 20: Introduction to MINA - Apache MINA — Apache MINAmina.apache.org/mina-project/resources/ACAsia2006.pdfIntegration with Apache ASN.1 for complex protocols Users can build customized

20

Reverse Echo Server

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

codec in MINA

Example

Page 21: Introduction to MINA - Apache MINA — Apache MINAmina.apache.org/mina-project/resources/ACAsia2006.pdfIntegration with Apache ASN.1 for complex protocols Users can build customized

21

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

• Future• MINA as a Platform• Real-time Management• Participation

• Conclusion

Page 22: Introduction to MINA - Apache MINA — Apache MINAmina.apache.org/mina-project/resources/ACAsia2006.pdfIntegration with Apache ASN.1 for complex protocols Users can build customized

22

Integration with Apache ASN.1 for complex protocols

Users can build customized servers with ready-made protocol codecs.

Design custom protocols just like drawing a UML!

Real-Time Management System

LDAP

Kerberos

ASN.1Codec

MINA as a PlatformFuture

MINA Core Library

HTTP

SMTP

FTP

……

Popular Protocols

Visual Protocol Designer

(ASN.1-based)

Rapidly Prototyped

Protocol

Others

Page 23: Introduction to MINA - Apache MINA — Apache MINAmina.apache.org/mina-project/resources/ACAsia2006.pdfIntegration with Apache ASN.1 for complex protocols Users can build customized

23

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>

Future

Page 24: Introduction to MINA - Apache MINA — Apache MINAmina.apache.org/mina-project/resources/ACAsia2006.pdfIntegration with Apache ASN.1 for complex protocols Users can build customized

24

We Need Your Participation!

• Sounds exciting?• Your feedback is our blood!

• Ask questions• Criticize design flaws• Report bugs• Publish performance test results

Future

Page 25: Introduction to MINA - Apache MINA — Apache MINAmina.apache.org/mina-project/resources/ACAsia2006.pdfIntegration with Apache ASN.1 for complex protocols Users can build customized

25

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

• Conclusion

Page 26: Introduction to MINA - Apache MINA — Apache MINAmina.apache.org/mina-project/resources/ACAsia2006.pdfIntegration with Apache ASN.1 for complex protocols Users can build customized

26

Conclusion

• MINA is…• A network application framework for…

• Productivity• Performance• Stability

• MINA will be…• Full-featured dev. & mgmt. platform for

network applications

Conclusion

Page 28: Introduction to MINA - Apache MINA — Apache MINAmina.apache.org/mina-project/resources/ACAsia2006.pdfIntegration with Apache ASN.1 for complex protocols Users can build customized

Thank You!

Q & A