Fwd: How to handle server throttling client connections and HTTP 503 "Service Unavailable"
"이희승 (Trustin Lee)"
trustin at gmail.com
Mon Jan 10 01:03:26 EST 2011
Hi Tim,
On 11/18/2010 11:42 PM, Tim McCauley wrote:
>
> I am new to Netty and have found the API and Java docs to be very good.
>
> I am trying to put a server together that has two Http web servers in
> one JVM. The first server will have up to 200k + clients connected to
> it and they must stay connected all the time, using Https. The server
> has a RESTFUL protocol and one of the messages the clients will send is
> a simple GET with no content ever 95 to 120 seconds which will keep the
> connection alive. Then the clients will also send data in a JSON
> payload when necessary. The clients when connecting to the first server
> register with it using a unique id that the client and the second sever
> uses to communicate with it. So in the first server on initial contact
> it creates a mapping from the clients unique id and the channel id. The
> second server also uses a REST protocol and some of the messages result
> is sending messages connected to the first server. The second server
> uses the Channel to unique id mapping that was created on initial
> registration with the first server and the second server handler gets
> that Channel and writes the message to the client.
>
> I have a few question:
>
> 1) Will Netty be able to handle have 200K+ clients connected to a server
> socket and remain open all the time?
I think so, but it will highly depend on what your server do. If all
200k connections are busy. it is likely that you need a high performing
machine.
> 2) Is it correct for the second server to get the Channel on the first
> server to send message to the connected clients?
You can do that, but the client will see the message as it came from the
first server.
> 3) How can clients being connected to the server be throttled? What I
> mean is if say 10K clients all try to connect to the server how can an
> Http 503 "Service Unavailable" be communicated back to the client?
You need to maintain the stats by yourself and generate the 503 response
for the clients that didn't make the cut.
> I see when creating the NioServerSocketFactory that both the boss and
> worker Executors are passed and there is an optional number of worker
> threads. The docs are a little unclear as to how the optional number of
> worker threads works and what happens when they are all used up. When
> all the worker threads are used up what will Netty do.
I agree with you that the documentation assumes the reader has some
knowledge about general NIO programming. Let me fix it soon..
If all the worker threads are used up, Netty will assign more than one
channel to a worker thread so that a single thread handles more than one
channel, just like a usual non-blocking socket servers do.
> Great API
Thanks. If you have any suggestion for improvement, I'd love to listen to.
--
Trustin Lee, http://gleamynode.net/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 294 bytes
Desc: OpenPGP digital signature
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20110110/fc1e4e23/attachment.bin
More information about the netty-users
mailing list