I'm writing a web site in PHP which calls REST services via HTTP, using the standard "http_request" PHP function.
The first "http_request" call from my PHP scripts takes about 2 seconds to reply, while the subsequent calls to "http_request" take less than 0.1 seconds (if I need to call several REST services for one client request). The code:
$http_method = HTTP_METH_GET;
$http_url = '127.0.0.1:8080/sites/scheme/srv/user/1';;
$http_options = array('headers' =>
array( 'Session-Id' => $h_session_id, 'Date-Auth' => $h_date, 'Auth-Proof' => $h_auth_proof )
);
$info = array();
$start = getNowDateWithMicrotime2();
$http_reply = http_request($http_method, $http_url, null, $http_options, $info);
$stop = getNowDateWithMicrotime2();
echo "Request/Reponse times: $start => $stop";
Why ? Is there any HTTP connection pooling solution ? (the REST server called from my PHP scripts is always at the same IP address).