ajax - 使用HTTP2如何限制并发请求数?

标签 ajax nginx request http2

我们有一个系统client <-> server通过 HTTP1.1 工作。客户端正在向服务器发出数百(有时数千)个并发请求。

由于浏览器对 HTTP1.1 连接的默认限制,客户端实际上是以批量(6 ~ 8)个并发请求的方式发出这些请求,我们认为如果我们可以增加并发请求的数量,我们可以获得一些性能提升.

我们将系统转移到通过 HTTP2 工作,我们看到客户端按照我们的意愿同时请求所有请求。

现在的问题是相反的:服务器无法处理如此多的并发请求。

我们如何限制客户端同时执行的并发请求数量,以便服务器更易于管理?假设 50 ~ 100 个并发请求。

我们假设 HTTP2 可以让我们毕业并发数 连接:

With HTTP/2 the client remains in full control of how server push is used. The client can limit the number of concurrently pushed streams; adjust the initial flow control window to control how much data is pushed when the stream is first opened; or disable server push entirely. These preferences are communicated via the SETTINGS frames at the beginning of the HTTP/2 connection and may be updated at any time.

也在这里:

也许,如果可能的话,我们可以在服务器端限制它(我认为更易于维护)。

但看起来这些解决方案正在谈论 Server Push我们所拥有的是客户端拉动。

如果有任何帮助,我们的架构如下所示:

Client ==[http 2]==> ALB(AWS Beanstalk)  ==[http 1.1]==> nginx  ==[http 1.0]==> Puma

最佳答案

SETTINGS 框中有特殊设置

您可以在服务器端将SETTINGS_MAX_CONCURRENT_STREAMS指定为100

Reference

关于ajax - 使用HTTP2如何限制并发请求数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55080915/

相关文章:

php - 如何在 Nginx 上使用 Xdebug 和 Laravel,在 Mac 上使用 PHPStorm?

php - apache php > 用户请求

javascript - C# 中 ajax 函数不返回数据

javascript - asp.net MVC 部分查看如何初始化 javascript

php - nginx + nodejs + php

regex - 在 nginx 中使用正则表达式重定向子域

ajax - Windows Phone 7 WebBrowser 控件是否实现同源策略?

javascript - 如何在 ajax url 中传递 JavaScript 变量?

php - mysql | mysql |来自空列和 FIND_IN_SET 的请求

python - 无需包装器或使用 API : Python 即可访问 Google 趋势数据