Jeff Sanders Technical Blog

I am a Microsoft employee that has worked on all aspects of the Web Stack for a long time. I hope these blogs are useful to you! Use this information at your own risk.


<< Go Back

Understanding Connection Limits And New Proxy Connection Limits In Wininet And Internet Explorer

- 29 Jun 2009

Because of RFC 2616 section 8.1.4 (http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html) we have traditionally limited the number of persistent connections to 2 per server.  This is because of the strong language in this RFC: ” A single-user client SHOULD NOT maintain more than 2 connections with any server or proxy.”<?xml:namespace prefix = o ns = “urn:schemas-microsoft-com:office:office” />

Practically speaking with today’s modern web servers, there is no reason for such a small number of client connections to a server.  This is especially true with the rich WebPages and WebBased applications hosted in WebPages.  Indeed, at times you can get into a situation where you are attempting to download resources for a WebPage and a script is executed to download additional data giving the appearance of a web browser.  The ability to download several resources simultaneously has huge advantages when it comes to downloading resources quickly and gives the ability to provide a more responsive web experience.

While you could always change the number of connections WinInet (and Internet Explorer) used by default, in the past, you could not also control the number of Proxy Connections separately (also covered in RFC 2616).  There is now a setting that will allow you to set the proxy connection limit independent from the number of persistent connections to a server.

Here is a brief Q&A I put together to help you get your head around these settings:

What does setting the max Server and Proxy connections do?  This limits the number of possible connection at one time to a given host either direct or through a proxy.

What happens if I try to make 4 connections and the default number of persistent connections (proxy or server) is set to 2?  Two connections will be made and two will be put in a queue to ‘wait’ for an available connection to be freed.  Once one of the first two connections gets a response, another ‘waiting’ connection will use that available connection in a FIFO manner.

If my app has 2 requests to one host and 2 to another, does that mean only 2 connections at a time will be used total, and there will be two connections waiting?  No, this means that 2 connections per host will be used so in this example there will be no connections waiting.

Why limit the proxy connections in WinInet to begin with?  We always have as a function of limiting the HTTP connections to the end point server.  We did this because the RFC 2616 tells us to:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html  (see 8.1.4 Practical Considerations)

Why add a new limit for the proxy connections?  In the event you need to customize the number of proxy connections.  The default is set to 4 which is enough to satisfy the defaults for WinInet which is 2 for HTTP 1.1 servers and 4 for HTTP 1.0 servers. 

What was it before?  The value did not exist before so it is the same as the server settings.  If the proxy was Http 1.0 it was 4.  If it was http 1.1 it was 2. 

What if I want to have more server connections, should I also set the MaxConnections to proxy to follow this?  No!  The number of proxy connections will automatically follow the MaxConnections for the server, your application should probably do the same.  In most cases (unless your proxy has some other strange requirement) it should be the same as your server connections.  If for some reason you want this different then set the MaxConnectionsPerProxy manually.  If you do not have a reason for this to be different then do not use this setting.

How do I set the MaxConnectionsPerProxy?  Either in Code (see this blog: http://blogs.msdn.com/jpsanders/archive/2009/06/08/understanding-the-new-wininet-option-internet-option-max-conns-per-proxy.aspx) or with this registry setting:

Important This section, method, or task contains steps that tell you how to modify the registry. However, serious problems might occur if you modify the registry incorrectly. Therefore, make sure that you follow these steps carefully. For added protection, back up the registry before you modify it. Then, you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click the following article number to view the article in the Microsoft Knowledge Base:

322756  (<font color=#0000ff>http://support.microsoft.com/kb/322756/</font>) How to back up and restore the registry in Windows

To change the number of files that you can download through your proxy at one time to 2, follow these steps:

1.     Start Registry Editor.

2.     Locate the following key in the registry:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings

3.     On the Edit menu, point to New, click DWORD Value, and then add the following registry values:
Value name: MaxConnectionsPerProxy
Value data: 2
Base: Decimal

4.     Exit Registry Editor.

 

</p>

Let me know if this article was useful to you!

</span>

<< Go Back