parallel http requests php controlling pecl http classes [answer: httprequestpool class]
the category provides solution. interjection those separate out.
a brief educational found at:
problem
i'd concurrent/parallel/simultaneous http requests php. i'd prevaricate unwavering requests as:
- a set requests take too enlarged complete; some-more requests longer
- the timeout ask midst by set competence means after requests finished (if book an execution limit)
i have managed sum origination , however i'd definitely php's during possible.
specifically, i need post information parallel set urls. urls information posted over control; user-set.
i don't mind i need wait requests finish before responses processed. i set timeout 30 seconds any ask requests finished concurrently, i know i contingency wait border 30 seconds (perhaps small more) requests complete.
i sum competence achieved. however, i recently notice plead php authority php5+ being means hoop indicate http requests - i commanded note during time, forgot, can't again.
single ask instance (works fine)
<?php
$request_1 = new httprequest($url_1, http_meth_post);
$request_1->setrawpostdata($dataset_1);
$request_1->send();
?>
concurrent ask instance (incomplete, clearly)
<?php
$request_1 = new httprequest($url_1, http_meth_post);
$request_1->setrawpostdata($dataset_1);
$request_2 = new httprequest($url_2, http_meth_post);
$request_2->setrawpostdata($dataset_2);
// ...
$request_n = new httprequest($url_n, http_meth_post);
$request_n->setrawpostdata($dataset_n);
// something send() requests during same time
?>
any thoughts many appreciated!
clarification 1: i'd hang pecl http functions as:
- they offer good oop interface
- they're used extensively concentration doubt adhering what's already should profitable maintain perspective
- i generally have fewer lines formula an http ask controlling pecl http functions compared controlling twist - fewer lines formula should also profitable maintain perspective
clarification 2: i comprehend php's http functions aren't built maybe i worded things feeble there, i shall correct. i have concerns carrying exercise additional things - an concentration distributed, it's web app server itself.
clarification 3: i'd ideally happy someone authorised states pecl http can't this.
Comments
Post a Comment