High Performance(1)Events Threads Actors
Stream can be file, socket, pipe. I/O, read and write.
Blocking IO
One thread can only handle one IO, ask A and B to read and write through a buffer.
If we plan to deal with more IO in the same time, we need multiple threads or multiple processes.
RPC Model
Process per Connection, apache
TPC Model
Thread per Connection
NON-Blocking IO
Put all the IO in the chain, ask them one by one.
while true {
for i in stream[];{
if i has data
read until unavailable
}
}
select and poll (proxy)
If there is no IO event, thread/process sleep, once event happen, wake up the all streams and ask them one by one.
while true {
select(streams[])
for i in streams[]{
if i has data
read until unavailable
}
}
select Model
poll Model
event poll (proxy)
It will tell us which events are having IO, we only need to wake up the active streams and ask them one by one.
while true{
active_stream[] = epoll_wait(epollfd)
for i in active_stream[]{
read or write till unavailable
}
}
Epoll Model
Actor Model
Data + Behavior + Message
Thread can not call behavior in the Model, it will only send the message to the Model. (Disruptor, LMAX)
References:
http://www.zhihu.com/question/20122137
http://sillycat.iteye.com/blog/1767866
http://sillycat.iteye.com/blog/2099267
http://www.jdon.com/45728
High Performance(1)Events Threads Actors
猜你喜欢
转载自sillycat.iteye.com/blog/2101142
今日推荐
周排行