start server with more than one allowed RPCs

pull/6498/head
Jan Tattermusch 9 years ago
parent 65ca9dcabc
commit 26cc1427e9
  1. 7
      src/csharp/Grpc.Core/Server.cs

@ -48,6 +48,7 @@ namespace Grpc.Core
/// </summary> /// </summary>
public class Server public class Server
{ {
const int InitialAllowRpcTokenCount = 10;
static readonly ILogger Logger = GrpcEnvironment.Logger.ForType<Server>(); static readonly ILogger Logger = GrpcEnvironment.Logger.ForType<Server>();
readonly AtomicCounter activeCallCounter = new AtomicCounter(); readonly AtomicCounter activeCallCounter = new AtomicCounter();
@ -129,9 +130,15 @@ namespace Grpc.Core
startRequested = true; startRequested = true;
handle.Start(); handle.Start();
// Starting with more than one AllowOneRpc tokens can significantly increase
// unary RPC throughput.
for (int i = 0; i < InitialAllowRpcTokenCount; i++)
{
AllowOneRpc(); AllowOneRpc();
} }
} }
}
/// <summary> /// <summary>
/// Requests server shutdown and when there are no more calls being serviced, /// Requests server shutdown and when there are no more calls being serviced,

Loading…
Cancel
Save