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?

图片转代码服务由CSDN问答提供 功能建议

我有网站,从远程ftp服务器加载配置文件(每1个网页5-15个)(linux proftpd) 。

当用户打开(刷新)只有一个网页时 - 一切都很好,页面渲染速度很快(~100毫秒)。 当用户在网络浏览器上逐个打开4-6个标签(打开标签之间约1秒延迟)时,平均1-3个网页呈现快速,但4-6页它太懒(最多60秒或更长时间) 。

我发现了瓶颈:这是ftp_get()php函数,当从ftp获取文件时冻结到ftp_connect()中设置的超时时间。 只有ftp_get()冻结网页呈现。

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

我是ssh到远程ftp服务器并运行ftptop来查看页面冻结时的连接。 proftpd与COMMAND'RETR'只有一个连接。

ftp_get总是成功从ftp获取第一个(有时最多5个文件)文件,但是另一个文件总是空的(但是存在且不是空的 这个文件的ftp服务器和ftp_get超时。


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

尝试 ftp_pasv()

但没有:( ftp_get()和web- 页面仍然冻结了很多时间,并且没有加载每个网页末尾的文件内容。


  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • douyan7916 2014-02-07 12:03

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

    解决 无用
    打赏 举报

相关推荐 更多相似问题