[ 
https://issues.apache.org/jira/browse/THRIFT-3084?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14482396#comment-14482396
 ] 

James E. King, III edited comment on THRIFT-3084 at 4/7/15 4:07 AM:
--------------------------------------------------------------------

Refer to THRIFT-3083, it can be implemented as a very simple subclass with 
overrides on serve, onClientConnected, and onClientDisconnected:

1. Serve calls the base serve() (which does everything up to closing the sevrer 
transport) then waits on the monitor for notify.
2. onClientConnected adds to the tracking thread set; to satisfy this 
particular Jira enhancement, if the concurrent limit is reached following 
adding to the set, then enable the barrier.
3. onClientDisconnected removes from the tracking thread set, disables the 
barrier if the new set size is below the maxConnections limit, and notifies if 
it is fully drained to unblock the stop process (item 1).


was (Author: jking3):
Refer to THRIFT-3083, it can be implemented as a very simple subclass with 
overrides on serve, onClientConnected, and onClientDisconnected:

1. Serve calls the base serve() (which does everything up to closing the sevrer 
transport) then waits on the monitor for notify.
2. onClientConnected adds to the tracking thread set
3. onClientDisconnected removes from the tracking thread set, and notifies if 
it is fully drained

> 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
>
> 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.



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

Reply via email to