也许有人可以回答我这个问题.在我最近的工作中,我注意到我的应用程序(通过FTP下载更新)在与Linux一起使用时非常慢.我在Mac上开发这些东西,所以我之前没有注意到这个问题,因为Mac OS下的下载速度并不是很低.但是当转向Linux时,应用程序表现得非常不同.
FTP服务器(在Ubuntu服务器上运行的纯FTP)连接到与客户端相同的LAN,因此不考虑Internet速度问题.由于性能低下,我将Apache FTPClient更改为edtFTPj/Free.差异仍然显着但可以接受.作为测试用例,我总是下载大小约为30 MB的文件.然后我检查了ftp服务器日志以了解传输速率.
你自己看.提到的VMWare在Mac上运行.除非另有说明,否则Java是Oracle Java 1.7.
代码看起来像这样
FTPClient ftp = new FTPClient();
ftp.connect("srv0006");
ftp.login("anonymous", "asd");
ftp.setFileType(FTP.BINARY_FILE_TYPE);
File target = new File("/tmp/pub.tar");
FileOutputStream fos = new FileOutputStream(target);
ftp.retrieveFile("/pub.tar", fos);
fos.close();
Run Code Online (Sandbox Code Playgroud)
以下是ftp日志的结果
downloaded (30452736 bytes, 21200.67KB/sec)
Run Code Online (Sandbox Code Playgroud)
downloaded (30452736 bytes, 21471.75KB/sec)
Run Code Online (Sandbox Code Playgroud)
downloaded (30452736 bytes, 65243.15KB/sec)
Run Code Online (Sandbox Code Playgroud)
downloaded (30452736 bytes, 5274.56KB/sec)
Run Code Online (Sandbox Code Playgroud)
downloaded (30452736 bytes, 7663.68KB/sec)
Run Code Online (Sandbox Code Playgroud)
在与千兆以太网连接的另一台PC上运行到同一LAN.其他Ubuntu机器的行为方式完全相同.我在20分钟后退出了转会.查看转移率.
downloaded (7077888 bytes, 6.10KB/sec)
Run Code Online (Sandbox Code Playgroud)
在此之后,我转到了edtFTP4j.结果好多了.
FileTransferClient ftp = …Run Code Online (Sandbox Code Playgroud)