duanlian1960 2015-08-06 16:52
浏览 144

PHP curl文件描述符限制导致请求失败

I have a small PHP script that is doing (ideally) 10,000 multi curl requests, in a 250 rolling window. I'm using chuyskywalker/rolling-curl library and I've compiled php/curl/c-ares from source to enable AsynchDNS.

At first it was working great and I was very happy with it however I've noticed that after 1000ish requests (1024 maybe..) curl just seems to send the requests then give up and say it couldn't contact the DNS server.

I believe this has something to do with the file descriptor limits because when I did ulimit -Sn I saw it was at 1024 (same place curl starts giving up) so I upped the limit and it managed to get further through the run then I lowered the limit back down and it stopped in the same place again. I've currently set the limit to 65535 by changing /etc/security/limits.conf to

* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535

and I thought all was fixed until I tried a 10,000 url run with the same 250 rolling window then curl started giving up again but much later on in the run.

By doing cd /proc/procid/fd and ls -l | wc -l I can see the process is getting to 6500 file descriptors (not 65535) then causing the problems in the curl.

Can someone explain to me how curl uses these file descriptors? and if there is any way I can overcome this problem?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 ETLCloud 处理json多层级问题
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口
    • ¥15 不是,这到底错哪儿了😭
    • ¥15 2020长安杯与连接网探
    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
    • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
    • ¥15 可见光定位matlab仿真
    • ¥15 arduino 四自由度机械臂
    • ¥15 wordpress 产品图片 GIF 没法显示