【问题标题】:Disable Kestrel (dotnet asp.net core server) request queuing禁用 Kestrel (dotnet asp.net core server) 请求队列
【发布时间】:2019-11-13 02:55:08
【问题描述】:

如果一次命中太多请求,Kestrel(dotnet asp.net 核心服务器)会排队请求。我希望它抛出一个 503 而不是队列以避免超时。我们有

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

但如果超过 100 个请求,它仍然会排队,有些请求会超时。

【问题讨论】:

    标签: c# .net-core kestrel-http-server


    【解决方案1】:

    MaxConcurrentConnections 属性指定 Kester 服务器在开始拒绝连接之前可以接受的连接数。

    因此,换句话说,MaxConcurrentConnections 指定了队列长度。在上面的示例中,如果它接受 100 个请求并处理它们,它将开始下降。

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

    如果您的网站每秒收到的请求少于 10 个,并且您在 5 秒内处理了这些请求,那么您会很好。

    此外,没有选项可以指定自定义 HTTP 错误代码。 TCP 连接将被服务器突然终止。你的客户端应该检测并处理网络错误。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-11-28
      • 1970-01-01
      • 2011-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-24
      相关资源
      最近更新 更多