提高php发送请求的响应速度

我在一个框架方法中用php的curl模拟发送了大量的请求,数量大约在300左右,系统经常出现运行超时的错误提示,有没有一种方法可以加快请求的执行速度在不修改php最大执行时间的前提下。。。

<?php
function step1()
{
sleep(1);
}

function step2()
{
sleep(5);
file_put_contents('filename.txt', '耗时任务已完成');
}

/**

  • 结束输出缓冲数据
  • @return [type] [description] */ function finishRequest(){ ignore_user_abort(true); // 客户端关闭程序继续执行 if(function_exists('fastcgi_finish_request')) { fastcgi_finish_request(); // 响应完成, 关闭连接。只在FastCGI有效 } else { header('X-Accel-Buffering: no'); // nginx 不缓存输出 header('Content-Length: '. strlen(ob_get_contents())); header("Connection: close"); header("HTTP/1.1 200 OK"); ob_end_flush(); flush(); } }

step1();
echo "您的请求已完成";
finishRequest();
step2();

可以尝试使用curl_multi_init 并发执行多curl 节约执行时间