Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

Make your likes visible on Facebook?

Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.

No, thanks

Netty

네티의 전반적인 이해를 도와주는 프레지
by

Seongsik Kim

on 18 March 2015

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of Netty

Netty.
Introduction
Asynchronous?
non-blocking?
Netty

An Asynchronous Event-Driven Network Application Framework
HIGH Cuncurrent Connection
https://blog.twitter.com/2011/twitter-search-now-3x-faster
블랜더는 자바기반의 쉽게 스케일링 가능한 NIO 클라이언트 서버 라이브러리인 로 개발된 Thrift, HTTP 서버입니다.
Netty
Low Memory Comsumption
Easy To Use NIO Library Wrapper
Magpie Nest API
PUT API
사용자의 요청 파싱
HBase에 저장
http://group1.magpie.daum.net/magpie/put/
{key}
?
{hash}
단순, 간단
Then
Event-Driven
이면 크게 성능 향상이 되지 않을까??
Event-driven?
request
request
Server
Handler Thread
request
Handler Thread
Handler Thread
VS
Server
Handler
Handler
Handler
Dispatcher
selector
"Reactor Pattern", "Event Dispatcher" or
"Event Loop"
Call Back
Handler
Handler
Handler
Dispatcher
selector
Channel Pipeline
구조는..?
코드
ServerBootstrap
객체만들기
channelFactory 필요...
channelFactory만들기
Executor(thread pool)필요..
쓰레드풀 만들기
ServerBootstrap객체에
pipelineFactory
할당
pipelineFactory.getPipeline();
Bootstrap 포트 바인딩..
ServerBootstrap
ChannelConfig
NioSocketChannelConfig
SocketChannelConfig
"connectionTimeoutMillis"
"bufferFactory"
"pipelineFactory"
keepAlive
reuseAddress
soLinger
tcpNoDelay
sendBufferSize
trafficClass
writeBufferHighWaterMark
writeBufferLowWaterMark
writeSpinCount
receiveBufferSizePredictor
receiveBufferSizePredictorFactory
ServerBootstrap
Codecs
Google ProtoBuf Encoder/Decoder
Compressor/Decompresser
HTTP Request Decoder, HTTP Response Encoder
Base64 Encoder/Decoder
Custom Handlers
ChannelPipeline
from http://seeallhearall.blogspot.kr/2012/05/netty-tutorial-part-1-introduction-to.html
SimpleUpstreamHandler Event
messageReceived(
ChannelHandlerContext

ctx
,
ChannelEvent

e
)
channelBound(
ChannelHandlerContext

ctx
,
ChannelEvent

e
)
channelUnbound(
ChannelHandlerContext

ctx
,
ChannelEvent

e
)
channelClose(
ChannelHandlerContext

ctx
,
ChannelEvent

e
)
channelOpen(
ChannelHandlerContext

ctx
,
ChannelEvent

e
)
...
channelInterestChanged(
ChannelHandlerContext

ctx
,
ChannelEvent

e
)
writeComplete(
ChannelHandlerContext

ctx
,
ChannelEvent

e
)
ServerBootstrap
ChannelFactory
ChannelPipelineFactory
bossExecutor
workerExecutor,
(max thread)
Pipeline
codec
channelDownstreamHandler
channelUpstreamHandler
setOption
TcpNoDelay
keepAlive
sendBufferSize
reuseAddress
Nagle 알고리즘
상대적으로 thread수가 적다.
thread간 컨텍스트 스위칭 오버헤드 감소
IO 자원의 읽기/쓰기 가능 상태를 기다리지 않고 다른 작업을 한다.
CPU 자원을 효율적으로 사용한다.
성능향상!
함정
Netty가 아무리 자원을 효율적으로 써도 자원이 풍부하다면,
1 request per 1 thread

모델이 더 빠르다.
보통 0~1000 thread까지는 tomcat이 성능이 더 좋음.
Full transcript