I am doing a project to create a file transfer proxy using netty, which should handle high concurrency efficiently.
Here is my structure:
Back Server , a regular file server, like the Http (File Server) example on netty.io, which receives and confirms a request and sends the file either using ChunkedBuffer or with a zero copy.
Proxies with both NioServerSocketChannelFactory and NioClientSocketChannelFactory using cachedThreadPool, listening for client requests and retrieving a file from Back Server back to clients. As soon as a new client is received, the new received channel (channel1) created by NioServerSocketChannelFactory, and waits for a request. After receiving the request, the Proxy will establish a new connection to the Back Server using NioClientSocketChannelFactory, and the new channel (channel2) will send a request to the Back Server and provide a response for the client. Each channel1 and channel2 use their own pipeline.
Simply put, the procedure
received channel1
channel1 receives a request
channel2 connected to back server
channel2 send request to Back Server
channel2 ( ) Back Server
channel1 , 2,
, 2 1 ( )
(10M), channel2.readable, channel1 , Proxy Server netty.io.
, .
ab ( apache), - . Proxy, Back Server Client - , .
:
10 , concurrency 1, , concurrency 1 10, 1% - ,
3 . 99% . concurrency 20, 1% 8 . ab , concurrency 100. 90% concurrency, 1% concurrency ( ).
1K, concurrency 100.
, .
- , ? , ping-pang, . , , :)
!
=============================================== =========================================
, . NioServerSocketChannelSink.bind() Boss.run(), for . AbstractNioWorker.register(), , .
register(), , startStopLock, . startStopLock AbstractNioWorker.run() AbstractNioWorker.executeInIoThread(), , . , startStopLock . AbstractNioWorker.register(), for Boss.run() , . , .