0

给定一堆同步的 Web 请求,按顺序执行 - 完成 Web 请求需要几秒钟,并且每秒N接收字节数。B然而,做同样的事情,但使用异步 Web 请求,这使得并行执行所有 Web 请求成为可能 - 它不再需要N几秒钟,但它仍然会B每秒接收字节数。

运行一个简单的测试,包含 12 个 Web 请求 - 同时使用同步和并行方法,确认它们都B每秒接收字节(使用Resource Monitor)。

因此,我的问题是......并行执行 Web 请求的方法是否应该每秒接收不超过B字节数,以弥补它比同步方法更快?- 否则同步方法将运行更长的时间,并且接收比并行方法更多的字节(总计)。

4

1 回答 1

0

These requests are not processed on your machine (unless connecting to localhost). This means that for each request to be fully processed, your machine will have to wait for a response.

Consider sending an invitation for your birthday party to friend #1, and after receiving a response, send one to friend #2, etcetera. It would be faster to send the invitation to all friends, and then wait for all of them to respond. Especially if friend #1 happens to be on holiday.

I don't know why the number of bytes per second are identical, perhaps some node in the network limits the speed, but the parallel approach can at least send out each request and "parallel out" the total wait time.

I don't understand how the synchronicity could affect the total number of bytes received. You're talking about bytes/second, but not the number of seconds spent at that transfer speed.

于 2013-06-22T21:31:08.213 回答