简体   繁体   English

使用 HTTP2 如何限制并发请求的数量?

[英]Using HTTP2 how can I limit the number of concurrent requests?

We have a system client <-> server working over HTTP1.1.我们有一个通过 HTTP1.1 工作的系统client <-> server The client is making hundreds (sometimes thousands) of concurrent requests to the server.客户端向服务器发出数百(有时数千)个并发请求。

Because the default limitations of the browsers to HTTP1.1 connections the client is actually making these requests in batches of (6 ~ 8) concurrent requests, we think we can get some performance improvement if we can increase the number of concurrent requests.因为浏览器对 HTTP1.1 连接的默认限制,客户端实际上是分批(6~8)个并发请求发出这些请求,我们认为如果我们可以增加并发请求的数量,我们可以得到一些性能提升。

We moved the system to work over HTTP2 and we see the client requesting all the requests simultaneously as we wanted.我们将系统移到 HTTP2 上工作,我们看到客户端根据我们的需要同时请求所有请求。

The problem now is the opposite: the server can not handle so many concurrent requests.现在的问题恰恰相反:服务器无法处理这么多并发请求。

How can we limit the number of concurrent request the Client is doing simultaneous to something more manageable for the server?我们如何将客户端同时执行的并发请求数量限制为服务器更易于管理的事情? let's say 50 ~ 100 concurrent requests.假设 50 ~ 100 个并发请求。

We were assuming that HTTP2 can allow us to graduate the number of concurrent connections:我们假设 HTTP2 可以让我们对并发连接数进行分级:

With HTTP/2 the client remains in full control of how server push is used.使用 HTTP/2,客户端可以完全控制服务器推送的使用方式。 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.这些首选项通过 HTTP/2 连接开始时的 SETTINGS 帧进行通信,并且可以随时更新。

Also here:也在这里:

O maybe, if possible, we can limit this in the server side (what I think is more maintainable).哦,如果可能的话,我们可以在服务器端限制它(我认为更易于维护)。

But looks like these solutions are talking about Server Push and what we have is the Client Pulling.但看起来这些解决方案是在谈论服务器推送,而我们所拥有的是客户端拉取。

In case help in any way our architecture looks like this:如果有任何帮助,我们的架构如下所示:

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

There is special setting in SETTINGS frame SETTINGS框中有特殊设置

You can specify SETTINGS_MAX_CONCURRENT_STREAMS to 100 on the server side您可以在服务器端将SETTINGS_MAX_CONCURRENT_STREAMS指定为100

Reference 参考

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

相关问题 可在Apache上启动的Ajax请求数量是否有限制 - Is there a limit to the number of Ajax requests that can be launched on Apache 如何限制Ajax POST请求的数量? - How to limit the number of ajax POST requests? 加入并发/相同的HTTP GET请求? - Joining concurrent/identical HTTP GET requests? 在给AJAX上传请求提供多文件支持的同时,我该如何对其速度进行限制? - How can I rate limit my AJAX upload requests while also giving it multiple file support? 使用Chrome扩展程序中的AJAX请求检测URL是否支持HTTP2? - Detect if URL supports HTTP2 using AJAX request in Chrome Extension? 如何以一种不可篡改的方式确定http请求的顺序? - How can I determine the order of http requests in a way that can't be tampered with? 如何限制angularjs中的$ http请求? - How do I throttle $http requests in angularjs? 为什么浏览器限制并行HTTP请求 - why do browsers limit parallel HTTP requests AJAX请求:如何为未处理的HTTP状态代码实现“其他”条件? - AJAX requests: How can I implement an “else” condition for unhandled HTTP status codes? 使用axios在Vuejs页面中的多个并发请求 - Multiple concurrent requests in a Vuejs page using axios
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM