title: What is limiting the # of simultaneous connections my ASP.NET application can make to a web service?
body: <p>I have an ASP.NET 4.0 application running atop IIS 7.5 on a 64-bit Windows Server 2008 R2 Enterprise machine with gobs of RAM, CPU, disk, etc.</p>
  
  <p>With every web request, the ASP.NET application makes a connection to a backend web service (via raw sockets), which is running on the same machine.</p>
  
  <p><strong>Problem:</strong> There appears to be something limiting the # of simultaneous connections to the backend web service.  Suspiciously, the number of concurrent connections is topping out at 16.</p>
  
  <p>I found this key article from Microsoft explaining how to tweak IIS' settings to accomodate ASP.NET apps that make lots of web service requests: <a href="http://support.microsoft.com/?id=821268#tocHeadRef" rel="noreferrer">http://support.microsoft.com/?id=821268#tocHeadRef</a></p>
  
  <p>I followed the article's recommendatinos, but still no luck.  The setting that is particularly interesting is the <code>maxconnection</code> setting, which I even bumped to 999.</p>
  
  <p><strong>Any ideas what <em>else</em> could be throttling connections?</strong></p>
  
  <p><strong>Note:</strong> When I cut IIS out of the mix and have the clients connect directly to the backend web service, it will happily open as many connections as I need, so I'm positive the backend is not the bottleneck.  It must be something in IIS/ASP.NET-land.</p>
  
  <p>Here's the relevant section of the <code>machine.config</code> which I'm sure is being read by the application (verified with <code>appcmd.exe</code>):</p>
  
  <pre><code>&lt;system.web&gt;
      &lt;processModel autoConfig="false" maxWorkerThreads="100" maxIoThreads="100" minWorkerThreads="50" /&gt;
      &lt;httpRuntime minFreeThreads="176" minLocalRequestFreeThreads="152"/&gt;
  
      &lt;httpHandlers /&gt;
  
      &lt;membership&gt;
          &lt;providers&gt;
              &lt;add name="AspNetSqlMembershipProvider"
                  type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
                  connectionStringName="LocalSqlServer"
                  enablePasswordRetrieval="false"
                  enablePasswordReset="true"
                  requiresQuestionAndAnswer="true"
                  applicationName="/"
                  requiresUniqueEmail="false"
                  passwordFormat="Hashed"
                  maxInvalidPasswordAttempts="5"
                  minRequiredPasswordLength="7"
                  minRequiredNonalphanumericCharacters="1"
                  passwordAttemptWindow="10"
                  passwordStrengthRegularExpression="" /&gt;
          &lt;/providers&gt;
      &lt;/membership&gt;
  
      &lt;profile&gt;
          &lt;providers&gt;
              &lt;add name="AspNetSqlProfileProvider" connectionStringName="LocalSqlServer" applicationName="/"
                  type="System.Web.Profile.SqlProfileProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /&gt;
          &lt;/providers&gt;
      &lt;/profile&gt;
  
      &lt;roleManager&gt;
          &lt;providers&gt;
              &lt;add name="AspNetSqlRoleProvider" connectionStringName="LocalSqlServer" applicationName="/"
                  type="System.Web.Security.SqlRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /&gt;
              &lt;add name="AspNetWindowsTokenRoleProvider" applicationName="/"
                  type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /&gt;
          &lt;/providers&gt;
      &lt;/roleManager&gt;
  &lt;/system.web&gt;
  &lt;system.net&gt;
      &lt;connectionManagement&gt;
          &lt;add address="*" maxconnection="999"/&gt;
      &lt;/connectionManagement&gt;
  &lt;/system.net&gt;
  </code></pre>