4. ✔ 자바 네트워크 어플리케이션 프레임워크
✔ 비동기 이면서 이벤트 기반
• tomcat < 10,000 (connection) VS netty < 100,000 ~ 1,000,000 (connection)
✔ I/O 처리를 위한 추상화 API 제공
• NIO, OIO, AIO… 처리에 대해 쉽게 쉽게 바꿀 수 있게 Netty I/O API 단에서 제공
✔ 잘 정의된 이벤트 모델과 스레드 모델 제공
• 접속을 맺고, 데이터를 보내고 받고, 접속을 끊을 때 어떤 이벤트가 발생할지 Netty가 잘 정의하여 제공
• 사용자의 코드가 어느 스레드에서 언제 실행 될 지, 불필요한 동기화 방지..등등 Netty가 잘 정의하여 제공
✔ 유연한 이벤트 처리 위한 bi-directional chain of responsibility pattern
✔ 직접 구현한 버퍼풀을 이용한 성능 이점 제공
• Buffer Zero-file-copy, Buffer Automatic Capacity Extession…
네티란?
10. ✔ 기존 이벤트 모델 (객체호출)
이벤트모델
✔ 새 이벤트 모델 (메서드호출)
Channel DisConnectedChannel UnboundChannel Closed
Message Event(in,out)
Channel ConnectedChannel boundChannel Open
Flush (Messag Event대체)Channel InActiveChannel Unregistered
InboundBufferUpdatedChannel ActiveChannel Registered
버퍼에 데이터를 다 채운 후
Flush 요청시 실제 I/O수행
통신가능상태
통신불가상태
* UserEventTriggered 메서드 추가
12. ✔ 이벤트 루프는 항상 싱글 스레드로 실행 되어짐
✔ 비동기 요청에 대한 결과 통보는 이벤트 루프 스레드에서 이루어짐
✔ 핸들러 메소드를 호출할 때 각 호출 사이에는 happens-before 관계 성립
✔ @Sharable 가 붙어 있지 않은 경우 핸들러 메서드를 동시 호출 하지 않음
스레드모델
eventloop
(single thread) pipeline handler
method
method
happens-before
volatile (필요없음)
ChannelFuture<T> handler 동시 호출(X)
14. ✔ Bootstrap
• Bootstrap : Client-side Channel를 생성 해 주고 새로운 연결을 시도 하는 Helper Class
• ServerBootstrap : Server-side Channel를 생성 해 주고 새로운 연결을 시도 하는 Helper Class
부모채널은 연결을 받아주고, 성공적으로 bound 되어진 client연결은 자식채널임
✔ EventLoop
•EventLoop : SingleThread Channel Seletor (OioEventLoop, Nio…, Epoll..)
•EventLoopGroup : MultiThread Channel Seletor (OioEvnetLoopGroup, Nio…, Epoll…)
✔ Channel
•NioSocketChannel, OioSocketChannel, EpollSocketChannel
NioServerSocketChannel, OioServerSocketChannel, EpollServerSocketChannel
✔ ChannelOption
•SO_KEEPALIVE, SO_SNDBUF, SO_RCVBUF, SO_TIMEOUT, SO_BACKLOG….
✔ ChannelFuture
• Channel I/O Operations이 완료 되었을 때 결과를 받을 수 있는 Future 객체
개발구성요소 (핵심컴포넌트)
15. ✔ ChannelHandler
• …InboundHandler, …OutBoundHandler 지원
• Channel I/O Operations의 Event 처리를 위한 Handler Method를 지원
✔ ByteBuf (dynamic buffer)
• UnPooledDirectByteBuf, UnPooledHeapByteBuf, UnPooledUnsafeDirectByteBuf,
PooledDirectByteBuf, PooledHeapByteBuf, PooledUnsafeDirectByteBuf,
CompositeByteBuf….
개발구성요소 (핵심컴포넌트)