dongsimang4036 2012-10-16 14:41 采纳率: 100%
浏览 46

第一次很长时间从PHP调用http_request

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).

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 使用EMD去噪处理RML2016数据集时候的原理
    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
    • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
    • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
    • ¥15 如何在炒股软件中,爬到我想看的日k线
    • ¥15 seatunnel 怎么配置Elasticsearch
    • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
    • ¥15 (标签-MATLAB|关键词-多址)
    • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
    • ¥500 52810做蓝牙接受端