Skip to content

Commit

Permalink
Add link to concurrent iterators
Browse files Browse the repository at this point in the history
  • Loading branch information
kelunik committed May 9, 2020
1 parent 7d9a620 commit 036f0f4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/concurrent.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The HTTP client allows making multiple requests concurrently. It leverages non-b
Instead of sending one request, waiting for the response, then doing something different like sending another request, we can use the time we're usually waiting for the server to respond to send a second request to another (or the same) server.

{:.table-no-border .table-full-width .table-text-center}
| ![sequential requests]({{ site.baseurl }}/images/requests-sequential.svg)<br>*Sequential Requests* | ![parallel requests]({{ site.baseurl }}/images/requests-parallel.svg)<br>*Parallel Requests* |
| ![sequential requests]({{ site.baseurl }}/images/requests-sequential.svg)<br>*Sequential Requests* | ![concurrent requests]({{ site.baseurl }}/images/requests-parallel.svg)<br>*Concurrent Requests* |

As you can see in the sequence diagrams, we save some time there. We only have to wait for the maximum response delay of both requests instead of the sum of both. With more requests this speedup is even more interesting.

Expand All @@ -33,3 +33,5 @@ foreach ($urls as $url) {

$responses = Amp\Promise\wait(Amp\Promise\all($promises));
```

If you need to perform a large set of requests, have a look at [concurrent iterators](https://amphp.org/sync/concurrent-iterator).

0 comments on commit 036f0f4

Please sign in to comment.