Slow Upload to IIS Server

iis-7.5iis-8.5tcpwebdavwindows-server-2012-r2

I have a Windows Server 2012 R2 running on an Amazon EC2 instance with IIS 8.5. It hosts a web application, and a custom WebDAV server that interacts with the same database as the web application.

I did some speed tests uploading files via the web application and the custom WebDAV server. I noticed that file uploads via WebDAV, using Microsoft’s built-in mini-redirector, were very slow – around 300 kB/s. Uploads via the website using Chrome were 10+ MB/s as expected.

I have the exact same code for the web application and WebDAV server running on a different server, running Windows Server 2008, and IIS 7.5 and the upload speed is 10+ MB/s on both the web application and the WebDAV server. So I am pretty sure there is nothing in my code that is causing the slow upload. I have spent several days researching this issue and have not been able to get my upload speeds where they should be to the WebDAV server.

Another interesting note: I tried uploading to the web application using Internet Explorer, and the upload speed was slow – about 300 kb/s just like when using mini-redirector to connect to the WebDAV server. I tested Firefox as well, and it was like Chrome, at 10+ MB/s.

I opened up Fiddler to examine the Request/Responses, and while Fiddler is open, the problem does not occur, the upload speed is 10+ MB/s, so I can’t gain any useful information from Fiddler.

I’ve used Wireshark to examine the TCP packets and compare the differences between my Windows Server 2008, which works fast, and Windows Server 2012 which is slow.

The order and size of the TCP is packets is the same, Two packets and an ACK, two packets and an ACK, etc. The Packet sizes are both about 4k. The only difference is the rate at which the packets are sent, which is several orders of magnitude faster on Windows Server 2008.

I’ve tested the upload speed on several different client machines – Linux, Windows 7, and Windows 8. I’ve only seen the issue occur on Windows 7, although that might be coincidence. It occurs on about 75% of Windows 7 machines, but not all Windows 7 machines.

This all leads me to believe that this issue must a combination of client/server side configuration, since I can’t pin the issue down to occurring on a specific server, or specific client only. In fact, I have set up another Windows Server 2008, identical to the current one where the upload works fast, but on the new server, the upload is still slow. So maybe the difference is the NIC, or maybe a specific hotfixes and patches, drivers, etc.

Here are some things I have tried in order to get my upload speed to increase on Windows Server 2012 R2:

• Increased Winsock SocketSendBuffer length in registry on client machines

• Disabled Nagle Algorithm on Server

• Disabled TCP Chimney Offload on server

• Enabled/Disabled about 50 other TCP related options that I have read about on various articles online.

• Tried connecting client from multiple network locations (if a client is slow to upload, it is slow regardless of where it is connecting).

• Tried HTTP instead of HTTPS, and the problem still occurs, so doesn’t appear to be related to SSL or TLS.

• Ensured, Auto-Detect proxy and auto-config script where unchecked in IE

• Ensured that keep-alive is enabled in client request headers

Does anybody have any ideas on what could be causing my slow upload issue?

Just to reiterate, the problem does NOT occur using Chrome or Firefox to upload via the web application, but does occur using IE. And the issue always occurs using mini-redirector on some client machines, but never occurs on others.

Best Answer

I was able to fix the issue by changing the Default Send Window for the Winsock driver - afd.sys - in the Windows Registry of the client computer.

Navigate to the following registry key and add a new DWORD with the name DefaultSendWindow and va value (decimal) of 1920000.

HKLM\System\CurrentControlSet\Services\AFD\Parameters

Note:

The value should be set at least as high as your advertised upload speed using the following equation:

(Upload Speed Kbps / 8 ) * 1024 = DefaultSendWindow

Example:

Advertised upload speed: 15 Mbps = 15,000 Kbps

(15000 / 8 ) * 1024 = 1920000

This value is generally overridden in code for 3rd party software, however Microsoft products do not seem to override it probably since they assume the default value used by their own afd.sys is sufficient. This why I was not seeing the problem using Chrome, Firefox, Filezilla, etc...as they were overriding this value themselves. It would seem that different file versions of afd.sys use different default send window values, which is why this bug was not showing up on all client machines.