简体   繁体   中英

Guzzle vs ReactPHP vs Amphp for parallel requests

What's the difference between:

How they differ and what would be typical use case to use with?

The main difference between those is that Guzzle is an HTTP client, while Amp and ReactPHP are generic async / event loop libraries. Both of these offer HTTP clients based on the core event loop they offer. Those are amphp/artax and reactphp/http-client .

Now, the difference between those and Guzzle is that those can do other things concurrently that are not HTTP requests. That is, because the user has full control over the event loop and can register own I/O watchers and timers, while the event loop that Guzzle uses is hidden from the user inside Curl.

If you just want to make a few concurrent HTTP requests, the decision mainly boils down to the API you like and a performance consideration maybe. If you want to do other I/O related things concurrently, use Amp or ReactPHP. If you want to stream your bodies, I'd suggest against using Guzzle, too.

Hey ReactPHP core team member here. Both ReactPHP and Amp assume you're building an app with an event loop. If you just want to do a bunch of async requests and then continue, I would suggest using Guzzle's async requests: http://docs.guzzlephp.org/en/stable/quickstart.html#async-requests

If how ever you want to dive deeper into async request I suggest https://github.com/clue/php-buzz-react which gives you more control over the process plus it supports PSR-7.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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