You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "James E. King, III (JIRA)" <ji...@apache.org> on 2015/04/06 20:19:13 UTC

[jira] [Comment Edited] (THRIFT-3084) C++ add concurrent client limit to threaded servers

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

James E. King, III edited comment on THRIFT-3084 at 4/6/15 6:18 PM:
--------------------------------------------------------------------

Good points, although TSimpleServer and TThreadPoolServer have essentially the same serve() loop in them that only differs where clients are handled  If you look at my proposal in THRIFT-3083 it should be clear this would be extracted such that TSimpleServer and TThreadPoolServer become small classes that implement onClientConnected and onClientDisconnected, and nothing more.  Extracting the common run loop for serve() will simplify maintenance and standardize server behavior in the same way THRIFT-3081 standardized the client run loop.

I would disagree that TSimpleServer should be free of object inheritance.  It is already a TServer so it is doing that.  We should consolidate the common serve loop as an example of good code reuse and maintainability practices to others.


was (Author: jking3):
Good points, although TSimpleServer and TThreadPoolServer have essentially the same serve() loop in them that only differs where clients are handled  If you look at my proposal in THRIFT-3083 it should be clear this would be extracted such that TSimpleServer and TThreadPoolServer become small classes that implement onClientConnected and onClientDisconnected, and nothing more.  Extracting the common run loop for serve() will simplify maintenance and standardize server behavior in the same way THRIFT-3081 standardized the client run loop.

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