duanchi3109 2014-02-06 11:46
浏览 118


I have website, wich loads config files (5-15 per 1 webpage) from remote ftp servers (linux proftpd).

When user opens (refresh) only one web-page - everything is fine, page renders to fast (~100 milliseconds). When user open 4-6 tabs one by one (~1 sec delay between opening tabs) on web browser, avg 1-3 web-pages renders to fast, but 4-6 pages it too sloooow (up to 60 seconds or more).

I find bottleneck: this is ftp_get() php function, that freeze to time of timeout set in ftp_connect() when getting files from ftp. Only ftp_get() freeze web-page rendering.

public function getConfigViaFtp($config_name)
    $handle = fopen('php://temp', 'r+');
    ftp_fget($this->getFtpConnectionStream(), $handle, $config_name, FTP_ASCII);

    return stream_get_contents($handle);

I am ssh to remote ftp server and run ftptop to look on the connections when page freeze. proftpd have only one connection with COMMAND 'RETR'.

ftp_get always succesfuly get first (sometimes up to 5 files) file from ftp, but another files always empty (but exists and not empty on the ftp server) and ftp_get timeouts on this files.

I try to:

$result = ftp_get($this->getFtpConnectionStream(), 'php://output', $config_name, FTP_ASCII);
$data = ob_get_contents();

try ftp_pasv()

but nothing :( ftp_get() and web-page still freeze a lot of time and doesn't load contents of files in end of each web-page.

Whats wrong? proftpd settings (default) or something else?

  • 写回答

1条回答 默认 最新

  • douyan7916 2014-02-07 12:03

    SOLVED: ftp_pasv() right after ftp_login(), but NOT after ftp_connect and everithing works fine :)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?



  • ¥15 爬取豆瓣电影相关处理
  • ¥15 手机淘宝抓清除消息接口
  • ¥15 C#无selenium
  • ¥15 LD衰减计算的结果过大
  • ¥15 用机器学习方法帮助保险公司预测哪些是欺诈行为
  • ¥15 计算300m以内的LD衰减
  • ¥15 数据爬取,python
  • ¥15 怎么看 cst中一个面的功率分布图,请说明详细步骤。类似下图
  • ¥15 为什么我的pycharm无法用pyqt6的QtWebEngine
  • ¥15 FOR循环语句显示查询超过300S错误怎么办