共用方式為


maxConnection setting may not work even autoConfig = false in ASP.NET

Case background:

Recently, we have a case that asp.net will consume the backend web service. We found the bottleneck was caused by the maxconnection to the remote web service.

We changed the maxconnection setting like below by following the KB821268 of old version:


maxconnection

 

The maxconnection parameter determines how many connections can be made to a specific IP address. The parameter appears as follows:

 

<connectionManagement>

    <add address="*" maxconnection="2">

    <add address="192.10.32.230" maxconnection="300">

</connectionManagement>

 

The settings for the parameters that are discussed earlier in this article are all at the process level. However, the maxconnection parameter setting applies to the AppDomain level. By default, because this setting applies to the AppDomain level, you can create a maximum of two connections to a specific IP address from each AppDomain in your process.

 

NOTE: before this, we already disabled autofig of processModel in machine.config

Unfortunately, we found that above configuration doesn’t take effect at all : the maxconnection is always 10.

Root Cause &Suggestions:

1. Actually the format of address like below mentioned in old KB article 821268 is inaccurate:


<connectionManagement>

    <add address="*" maxconnection="2">

    <add address="192.10.32.230" maxconnection="300">

</connectionManagement>

The address schema of maxconnection should be like below:

Http(s)://<IP address or Server Name>:<Non_Default_Port>

For example, below are some qualified addresses:

https://www.contoso.com

https://www.contoso.com:8088

https://www.contoso.com

https://10.172.5.34

2. As a prerequisite, Please do remember to disable autoConfig in machine.config as below:


<processModel autoConfig="false"/>

3. At the same time, KB 821268 of old version is modified already:

 

    <add address="*" maxconnection="2">

    <add address="192.10.32.230" maxconnection="300">

</connectionManagement>

b) Description of updated version:

 

 

<connectionManagement>

    <add address="*" maxconnection="2">

    <add address="https://192.10.32.230" maxconnection="12">

</connectionManagement>

 

If the application's code references the application by hostname instead of IP address, the parameter should appear as follows:

 

<connectionManagement>

    <add address="*" maxconnection="2">

    <add address="https://hostname" maxconnection="12">

</connectionManagement>

 

 

Finally, if the application is hosted on a port other than 80, the parameter has to include the non-standard port in the URI, similar to the following:

 

 

<connectionManagement>

    <add address="*" maxconnection="2">

    <add address="https://hostname:8080" maxconnection="12">

</connectionManagement>

References:

https://msdn.microsoft.com/en-us/library/4zt30szf(v=vs.80).aspx

 

Regards