简体   繁体   English

从同一源并行运行多个 Post 请求

[英]Running Multiple Post Request in parallel from the same source

I have a rest api backend server (NodeJs/Typescript) to which I am making a post request which return me a response.我有一个 rest api 后端服务器(NodeJs/Typescript),我正在向它发出一个发布请求,它会返回一个响应。 The thing is that I am trying to use my frontend to make about 8 post request calls at the same time with the same data (weird, I know) but that is the requirement of the project.问题是我正在尝试使用我的前端使用相同的数据同时进行大约 8 个 post 请求调用(我知道这很奇怪),但这是项目的要求。

Background: When I make one post call at the press of a button and then I refresh the page and press the button again.背景:当我按下一个按钮进行一个帖子调用,然后刷新页面并再次按下该按钮时。 The backend runs both of those requests in parallel.后端并行运行这两个请求。 This is what I want to do.这就是我想要做的。 So, I tried changing the front end code to make 5 post request at the call of the button but for some reason these request then get executed in sequence, meaning that I get one response and then the other request starts it execution as opposed to the page refers approach where they all start at the same time.因此,我尝试更改前端代码以在调用按钮时发出 5 个发布请求,但由于某种原因,这些请求随后按顺序执行,这意味着我得到一个响应,然后另一个请求开始执行,而不是页面指的是它们同时开始的方法。

I want to do this because the server won't get any requests and with this approach I am hoping to get sone sort of parallelization from the node environment.我想这样做是因为服务器不会收到任何请求,并且我希望通过这种方法从节点环境中获得某种并行化。

Each browser has a limit to the number or requests that can be fired on the same host - here .每个浏览器对可以在同一主机上触发的请求数量或请求都有限制 - 这里 When the limit is reached the requests are queued.当达到限制时,请求将排队。

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

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