[ 
https://issues.apache.org/jira/browse/THRIFT-3084?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

James E. King, III updated THRIFT-3084:
---------------------------------------
    Description: 
The TThreadedServer and TThreadPoolServer do not impose limits on the number of 
simultaneous connections, which is not useful in production as bad clients can 
drive a server to consume too many file descriptors or have too many threads.

With TThreadPoolServer one can set the limit on the number of threads, however 
the server will use one additional file descriptor because the serve() routine 
does not block until after accepting the threadManager size + 1 sockets.

With TThreadedServer there was no built-in way to throttle.

The solution is to add a Monitor to the TServerFramework and check the number 
of concurrent clients immediately before calling TServerTransport::accept() to 
get another client, and to track the number of clients that are still alive 
(their smart pointer hasn't been destroyed).


  was:
The TThreadedServer and TThreadPoolServer do not impose limits on the number of 
simultaneous connections, which is not useful in production as bad clients can 
drive a server to consume too many file descriptors or have too many threads.

1. Add a barrier to TServerTransport that will be checked before accept().

2. In the onClientConnected override (see THRIFT-3083) if the server reaches 
the limit of the number of accepted clients, enable the barrier.

3. In the onClientDisconnected override if the count of connected clients falls 
below the maximum concurrent limit, clear the barrier.  This will allow the 
limit to be changed dynamically at runtime (lowered) with drain off clients 
until more can be accepted.

Alternate proposal: Implement a Semaphore and have the servers block the 
serve() thread if the client that arrived puts the server at the concurrent 
client limit.


> C++ add concurrent client limit to threaded servers
> ---------------------------------------------------
>
>                 Key: THRIFT-3084
>                 URL: https://issues.apache.org/jira/browse/THRIFT-3084
>             Project: Thrift
>          Issue Type: Improvement
>          Components: C++ - Library
>    Affects Versions: 0.8, 0.9, 0.9.1, 0.9.2
>            Reporter: James E. King, III
>         Attachments: THRIFT-3084-on-3083.v2.patch
>
>
> The TThreadedServer and TThreadPoolServer do not impose limits on the number 
> of simultaneous connections, which is not useful in production as bad clients 
> can drive a server to consume too many file descriptors or have too many 
> threads.
> With TThreadPoolServer one can set the limit on the number of threads, 
> however the server will use one additional file descriptor because the 
> serve() routine does not block until after accepting the threadManager size + 
> 1 sockets.
> With TThreadedServer there was no built-in way to throttle.
> The solution is to add a Monitor to the TServerFramework and check the number 
> of concurrent clients immediately before calling TServerTransport::accept() 
> to get another client, and to track the number of clients that are still 
> alive (their smart pointer hasn't been destroyed).



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to