duanbi9202 2010-06-23 14:49
浏览 101
已采纳

PHP多线程CURL能力问题

I have a php script that comes down to the following:

while ($arr = mysql_fetch_array($result))
{
   $url = $arr['url'];
   exec("curl $url > /dev/null &");
} 

$url will represent a remote script.

My question is, what can I expect if I try to cycle through 2,000 URLs.

Will opening that many CURL connections cripple my server? Could I fire all 2000 in less than one minute?

What I am trying to do is prevent my users from having to setup cronjobs by opening connections and running their remote scripts for them.

Can you guys advise? I'm out of my league today.

Hudson

  • 写回答

2条回答 默认 最新

  • dongqindan4406 2010-06-23 14:52
    关注

    Take a look at curl_multi_init. It will not fire multiple processes so it should be softer on your server.

    I would advise you to fire only 3-15 at a time, depending on the load the server can handle and the complexity of the scripts. 2000 at a time will probably make you run out of file descriptors or other limit.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 基于单片机数字电压表电路组成及框图
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line