開発サーバーと運用サーバーの間でファイルを転送するために使用する ColdFusion アプリケーションがあります。実際にファイルを送信するコードは次のとおりです。
ftp = new Ftp();
ftp.setUsername(username);
ftp.setPassword(password);
ftp.setServer(server);
ftp.setTimeout(1800);
ftp.setConnection('dev');
ftp.open();
ftp.putFile(transferMode="binary",localFile=localpath,remoteFile=remotepath);
ftp.close(connection='dev');
上記のコードを使用してファイルを送信する場合、100KB/秒未満で上限を設定します (受信サーバーの FileZilla を介して監視)。Windows コマンドライン FTP ツールを使用してまったく同じファイルを送信すると、速度は 1000KB/s を超えます。
上記のコードだけでまったく新しいファイルを作成しましたが、それは転送速度に影響を与えないため、元のアプリケーションの周囲のコードとは何の関係もないことがわかります.
では、これらの異常に遅い速度の原因は何でしょうか?
編集:すべてのテストは、実稼働サーバーから開発サーバーにファイルを転送して行われています。<cfftp>
cfscript の代わりにタグを使用してみましたが、同じ結果が得られました。
編集#2:cfexecute
コードは次のとおりです。
私のFTPスクリプトから:
public function sendFiles(required string localpath, required string remotepath) {
this.writeFtpInstructions(localpath);
exe = "C:\Windows\system32\ftp.exe";
params = "-s:" & request.localapproot & "/" & "upload.txt";
outputfile = request.localapproot & '/ftp.log';
timeout = 120;
Request.cliExec(exe,params,outputfile,timeout);
}
public function writeFtpInstructions(required string localpath) {
instructions = request.localapproot & "/" & "upload.txt";
crlf = chr(13) & chr(10);
data = "";
data &= "open " & this.server & crlf;
data &= this.username & crlf;
data &= this.password & crlf;
data &= "cd " & request.remoteapproot & crlf;
data &= "put " & localpath & crlf;
data &= "quit";
FileWrite(instructions, data);
}
cliExec()
関数(cfscriptに相当するものがないため、ラッパーを作成する必要があります)cfexecute
:
<cffunction name="cliExec">
<cfargument name="name">
<cfargument name="arguments">
<cfargument name="outputfile">
<cfargument name="timeout">
<cfexecute
name="#name#"
arguments="#arguments#"
outputFile="#outputfile#"
timeout="#timeout#" />
</cffunction>