简体   繁体   English

禁用Kestrel(dotnet asp.net核心服务器)请求排队

[英]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.如果一次命中太多请求,Kestrel(dotnet asp.net 核心服务器)正在排队请求。 I want it to throw a 503 than queue instead to avoid timeout.我希望它抛出 503 而不是队列以避免超时。 We have我们有

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

But if more than 100 requests it would still queue up, and some requests just timeout.但是如果超过 100 个请求它仍然会排队,并且一些请求只是超时。

MaxConcurrentConnections property specifies the number of connections the Kester Server can accept before it starts rejecting the connections. MaxConcurrentConnections 属性指定 Kester 服务器在开始拒绝连接之前可以接受的连接数。

So, in other words, MaxConcurrentConnections specifies the queue length.因此,换句话说,MaxConcurrentConnections 指定了队列长度。 In the above example, it will start to drop if it accepted 100 requests and processing them.在上面的示例中,如果它接受 100 个请求并处理它们,它将开始下降。

https://github.com/aspnet/AspNetCore/blob/b31bdd43738a55e10bb38336406ee0db56c66b44/src/Servers/Kestrel/Core/src/Middleware/ConnectionLimitMiddleware.cs#L32-L39 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.如果您的站点每秒收到的请求少于 10 个,并且您在 5 秒内处理请求,那么您会很好。

Also, there is no option to specify a custom HTTP error code.此外,没有选项可以指定自定义 HTTP 错误代码。 The TCP connection will be terminated abrubtly by the server. TCP 连接将被服务器突然终止。 Youe client should detect and handle the Network Error. Youe 客户端应检测并处理网络错误。

Also refer this open issue: https://github.com/aspnet/AspNetCore/issues/4777另请参阅此未解决问题: https://github.com/aspnet/AspNetCore/issues/4777

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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