简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM