News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

VG Tech:
PHP Perform Requests in Parallel
July 23, 2013 @ 10:58:11

On the VG Tech blog today Espen Hovlandsdal has a quick tutorial showing you how to run cURL requests in parallel using the curl_multi_* functions included in PHP.

Ever had to request multiple HTTP-resources in your web application? Often, you need data from one request to be able to request the second - in this case there is little you can do but wait for the first to return. However, if the requests are not dependent on each other, you can use a pretty cool trick: curl_multi_*.

He first gives a single-threat example, showing how you might loop through a set of URLs to make the request and get the response. As an alternative, he shows the "multi" version right after. It sets up a "queue" of handles to different requests and executes them until they stop returning data. He also includes an example using the Guzzle HTTP client that makes it look cleaner and wraps some additional functionality around the requests.

0 comments voice your opinion now!
request parallel curl multiple tutorial guzzle

Link: http://tech.vg.no/2013/07/23/php-perform-requests-in-parallel

blog comments powered by Disqus

Similar Posts

The Bakery - Rails-Like Validation, Elistic, Textile, and a CakePHP Release

Stefan Mischook's Blog: Creating Your Own Functions - Part 2

HowTo Forge: Installing Lighttpd With PHP5 And MySQL Support On Mandriva 2008.0

Wokay.com: 12+ Tutorials for creating PHP5 MVC Framework

Juan Treminio: Unit Testing with PHPUnit Tutorial Series


Community Events





Don't see your event here?
Let us know!


symfony list install package library bugfix interview opinion deployment release community series language framework tips api podcast laravel introduction voicesoftheelephpant

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework