Performance
為什麼 FileZilla 比 PSFTP 快這麼多?
我正在使用 FileZilla 3.10.3 和 PSFTP 0.63 (PuTTY)。誰能幫我弄清楚為什麼我得到的吞吐量在兩個客戶端之間有如此大的差異?它不能只是 SFTP 協議的一個缺點,因為 FileZilla(和 WinSCP)要快得多!提前致謝。
當使用 FileZilla 使用某種協議連接到同一台伺服器時,我得到“良好”的吞吐量;一個大文件約 1.2MBPS。這是日誌:
Response: fzSftp started, protocol_version=2 Command: open "mecorp@ftp.themcorp.com" 22 Trace: Looking up host "ftp.themcorp.com" Trace: Connecting to 222.22.111.33 port 22 Trace: We claim version: SSH-2.0-PuTTY_Local:_Mar_29_2015_12:25:15 Trace: Server version: SSH-2.0-9.99 sshlib: 8.1.0.0 Trace: Using SSH protocol version 2 Trace: Doing Diffie-Hellman group exchange Trace: Doing Diffie-Hellman key exchange with hash SHA-1 Trace: Host key fingerprint is: Trace: ssh-dss 1024 20:88:a6:92:fe:11:db:b4:9a:b5:9e:8b:5f:50:bb:77 Trace: Initialised AES-256 SDCTR client->server encryption Trace: Initialised HMAC-SHA1 client->server MAC algorithm Trace: Initialised AES-256 SDCTR server->client encryption Trace: Initialised HMAC-SHA1 server->client MAC algorithm Command: Pass: ******** Trace: Sent password Trace: Access granted Trace: Opening session as main channel Trace: Opened main channel Trace: Started a shell/command Status: Connected to ftp.themcorp.com Trace: CControlSocket::ResetOperation(0) Status: Starting upload of c:\temp\test.zip Command: cd "/Home/mecorp" Response: New directory is: "/Home/mecorp" Trace: CControlSocket::ResetOperation(0) Trace: FileTransferSend() Command: put "c:\temp\test.zip" "test.zip" Status: local:c:\temp\test.zip => remote:/Home/mecorp/test.zip Trace: FileTransferParseResponse() Trace: CControlSocket::ResetOperation(0) Status: File transfer successful, transferred 27,974,088 bytes in 21 seconds
當使用 PSFTP 連接到使用相同協議的同一台伺服器並傳輸相同文件時,吞吐量會慢得多。我估計大約 150kbps(查看 Windows 7 任務管理器中的 I/O 字節)。這是日誌:
C:\temp>c:\d2\trunk\Util\psftp.exe -v -l mecorp -pw topsecret -P 22 ftp.themcorp.com Looking up host "ftp.themcorp.com" Connecting to 222.22.111.33 port 22 Server version: SSH-2.0-9.99 sshlib: 8.1.0.0 Using SSH protocol version 2 We claim version: SSH-2.0-PuTTY_Release_0.63 Doing Diffie-Hellman group exchange Doing Diffie-Hellman key exchange with hash SHA-1 Host key fingerprint is: ssh-dss 1024 20:88:a6:92:fe:11:db:b4:9a:b5:9e:8b:5f:50:bb:77 Initialised AES-256 SDCTR client->server encryption Initialised HMAC-SHA1 client->server MAC algorithm Initialised AES-256 SDCTR server->client encryption Initialised HMAC-SHA1 server->client MAC algorithm Using username "mecorp". Sent password Access granted Opening session as main channel Opened main channel Started a shell/command Connected to ftp.themcorp.com Remote working directory is /Home/mecorp psftp> put test.zip test.zip local:test.zip => remote:/Home/mecorp/test.zip psftp>
FileZilla 使用 PuTTY/psftp 原始碼進行 SFTP 實現。實際上 FileZilla 執行一個隱藏的 PSFTP 子程序。
但它使用自己的 PSFTP (
FzSFtp.exe
) 建構,幾乎沒有優化(和其他修改),包括:
- SFTP 傳輸隊列為 4 MB(與 PSFTP 中的 1 MB 相比)
- 以更大的塊分配記憶體(32 KB 與 515 B 相比)
- 使用大型網路緩衝區(SO_RCVBUF 為 4 MB,SO_SNDBUF 為動態大小$$ using SIO_IDEAL_SEND_BACKLOG_QUERY $$)。PSFTP 保持系統預設值。
FileZilla 還使用與 PuTTY (VS) 不同的編譯器 (mingw),這可能會有所幫助。
WinSCP 也基於 PSFTP 程式碼(儘管它在內部使用 PSFTP 程式碼,而不是在外部子程序中)並使用一組類似的優化。