stevemao
stevemao

Reputation: 1493

Disable Kestrel (dotnet asp.net core server) request queuing

Kestrel (dotnet asp.net core server) is queuing requests if too many requests are hit at one time. I want it to throw a 503 than queue instead to avoid timeout. We have

.UseKestrel(options => { options.Limits.MaxConcurrentConnections = 100; })

But if more than 100 requests it would still queue up, and some requests just timeout.

Upvotes: 2

Views: 3629

Answers (1)

Rajan Panneer Selvam
Rajan Panneer Selvam

Reputation: 1299

MaxConcurrentConnections property specifies the number of connections the Kester Server can accept before it starts rejecting the connections.

So, in other words, MaxConcurrentConnections specifies the queue length. In the above example, it will start to drop if it accepted 100 requests and processing them.

https://github.com/aspnet/AspNetCore/blob/b31bdd43738a55e10bb38336406ee0db56c66b44/src/Servers/Kestrel/Core/src/Middleware/ConnectionLimitMiddleware.cs#L32-L39

If your site receives less than 10 requests per second and you are processing the requests within 5 seconds, you will be good.

Also, there is no option to specify a custom HTTP error code. The TCP connection will be terminated abrubtly by the server. Youe client should detect and handle the Network Error.

Also refer this open issue: https://github.com/aspnet/AspNetCore/issues/4777

Upvotes: 2

Related Questions