2013年7月13日 星期六

有關FTP及Apache上傳速度卡住問題

Apache部分


regedit裡新增兩個十進位DWORD
[HKEY_LOCAL_MACHINE \SYSTEM \CurrentControlSet \Services \AFD \Parameters]
DefaultReceiveWindow = 327680
DefaultSendWindow = 327680

資料來源http://smallvoid.com/article/winnt-winsock-buffer.html

Configure the winsock default send- and receive-buffer size

12 October 2002 by Snakefoot | Comment » | Trackback Off
Usually when reading about TCPIP there is only mentioned one Receive Window for a connection, which is used to control congestion created by network latency.

In the WinNT network architecture a layer is placed on top of the TCPIP layer called AFD(Ancillary Function Driver for Winsock). The AFD provides the winsock interface, which is used by most network applications in Windows and is also supporting things like DNS and DHCP.

The AFD uses two windows which acts as a flowcontrol for the application creating the socket:
  • Send Window: Used when the application is sending data over a connection, if more data is sent than the receiver is able to acknowledge then the AFD-Send-Window will block the transfer for the application, when it reaches the limit of the AFD-Send-Window. The application creating the socket can use setsockopt to adjust SO_SNDBUF.
  • Receive Window: Acts just like the TCPIP-Receive Window, and when creating a Winsocket over TCPIP, then AFD will use the TCPIP Receive Window as AFD-Receive Window. The application creating the socket can use setsockopt to adjust SO_RCVBUF.
The default size of the two AFD-Windows is configured at boot time and is dependent on the available amount of physical memory:
  • 4096 bytes if less than 19 MByte RAM
  • 8192 bytes if more than 19 MByte RAM
If using a high latency or high bandwidth network then the AFD windows can affect performance. A small AFD-Send-Window will constantly be blocking the application sending data. A small AFD-Receive-Window will constantly be saturating the application receiving data (And blocking the remote sender). The two AFD-Windows should have the same value as the optimal TCPIP-Receive-Window to get the best speed.

To set the default size of the AFD-Windows use the following DWORD registry keys :
[HKEY_LOCAL_MACHINE \SYSTEM \CurrentControlSet \Services \Afd \Parameters]
DefaultReceiveWindow = 16384
DefaultSendWindow = 16384
Note that the AFD-Windows should be rounded to a multiple of memory page size (Usually 4096 Bytes). Not a multiple of the Maximum Segment Size(MSS) which is recommended for the TCPIP-Window.

Related : Recommended settings for the TCP/IP stack

More Info MSDN - Write Scalable Winsock Apps Using Completion Ports
More info MS KB Q214397
More info MS KB Q246984
More info MS KB Q311084


FTP部分


簡單來說就是transfer buffer size需要加大。之前我的設定32768結果卡在2MB/s(我的上限是4MB/s),改成3276800後現在正常了,寫在這邊供需要的人參考。

資料來源:http://trac.filezilla-project.org/ticket/820

Ticket #820 (closed Bug report)

Opened 8 years ago
Last modified 6 years ago

FileZilla Server incredibly slow

Reported by:prezlaOwned by:ci-dev
Priority:normalComponent:FileZilla Server
Keywords:Cc:prezla, ci-dev, codesquid
Operating system type:Operating system version:

Description 

FileZilla Server 0.9.5 is incredibly slow. I was
running it for and FTP server, but have since swapped
it out for WARFTPd 1.82.0.10 because of the following
performance numbers (notice that FileZilla is almost 3
times slower than WARFTPd, and Microsoft FTP is only
about 1 sec slower than WARFTPd):
FileZilla Server 0.9.5:

ftp> get catalog.pdf
200 Port command successful
150 Opening data channel for file transfer.
226 Transfer OK
ftp: 42509572 bytes received in 18.24Seconds
2330.95Kbytes/sec.
Microsoft FTP Server 5.1 (XP):

ftp> get catalog.pdf
200 PORT command successful.
150 Opening BINARY mode data connection for
catalog.pdf(42509572 bytes).
226 Transfer complete.
ftp: 42509572 bytes received in 8.14Seconds
5221.02Kbytes/sec.
WARFTPd 1.82.00-RC10:

ftp> get catalog.pdf
200 PORT command successful.
150 Opening BINARY mode data connection for catalog.pdf
(42509572 bytes).
226 Transfer complete. 42509572 bytes in 7.00 sec.
(5930.465 Kb/s)
ftp: 42509572 bytes received in 6.99Seconds
6080.61Kbytes/sec.
My platform is:
Intel Pentium III 933
512 MB RAM
Microsoft Windows XP SP2

Change History

Changed 8 years ago by codesquid 

Please have a look at the transfer buffer option in the
settings dialog. The default is 4096 which works best on
most systems. You may have to modify this value, especially
if you have modified any options of your TCP/IP stack or are
using the useless, so-called internet accellerators.

Changed 8 years ago by prezla 

Thanks for the response. Performance has improved
signicantly by increasing the transfer buffer to 16384.
Is there a reason why the default is 4096? I'm assuming
that the buffer is allocated for each connection. If this
is true, I would assume this is done to conserve memory?

Changed 6 years ago by codesquid 

The default buffer sizes have since been increased.

沒有留言:

張貼留言