IIS connections, number of concurrent connections, maximum number of concurrent worker threads, queue length, maximum number of worker processes

Source: Internet
Author: User
Tags postgresql server memory windows server versions

First.number of IIS connections

Generally purchased virtual host friends are familiar with the purchase, will limit the number of IIS connections, as the name implies that the IIS server can accommodate the maximum number of connections requested by the client, should be called "IIS limit the number of connections."

The connection content requested by the customer includes:

[1] web site HTML requests, image resources in HTML, script resources in HTML, other resources that need to connect to download, and so on, the request of any one resource is a connection (although some resources request connection response quickly)

[2] If a Web page is framed (nested Web requests within the framework), then a frame is connected once

[3] If a Web page pops up (a window nested inside a Web request), then a window is connected

Many people are very vague about the concept of connection numbers, and are now described as follows:
[1] Visitors to the site, must be connected with the site through the TCP protocol, establish a connection. This connection is present when the information is read from the server and is automatically closed at the end of the read. So, when a page has been completely displayed on the client's monitor, the connection used may have been turned off.
[2] Each browser, access to a site, may occupy more than 1-3 connections, which is automatically processed by the computer, the purpose is to speed up. Therefore, for a basic host with a connection number of 30, sometimes only more than 10 people can access it.
[3] Although the server can specify the maximum number of connections per site, but also there is a total number of server connections maximum. Therefore, even if the maximum number of connections for a user site is limited, the site cannot be accessed when the server reaches the maximum number of connections. The maximum number of connections to the server is typically 1000-2000.
[1] This is why the service provider dares to open an unlimited number of connections to the host, in essence, is not an unlimited number of connections.
[2] Western Digital provides the host, allows the number of connections are high, can generally meet user needs.

In IIS (version 6.2 and above), click on "Site", "right-click Switch to Features View", "Click on the right side of the" "Restrictions ..." Link, edit Site restrictions

Limiting the number of connections (N) is the standard for the number of IIS connections exposed by the virtual host, and if the number of IIS connections purchased is 50, then we have to consider the content framework and the amount of traffic to the site.

If there are enough pictures of the website, pop-up window random (may even time selection box, simple condition filter box also with pop-up new window), plus the forced to open a new page to browse content, then only can tolerate 10 people at the same time operation is also very normal, I will not describe this operation as many sites said "10 Simultaneous online", This is easy to misunderstand, in a user's request (on the surface may be refreshing a page, in fact, the internal request more than once, in fact, rarely only once) to complete the server response is completed, the connection will be released, of course, before you see the displayed page, internal nesting if the request picture and other connection requests, The connection will be released early.

In fact, many of the Enterprise Portal site access is surprisingly low, IIS connections of 50 is more than enough.

Second. IIS Maximum number of concurrent connections

"Manage Web sites" → "Advanced Settings ..." → "Limit" → "Maximum concurrent connections"

In fact, ordinary users often say "IIS connection number" Is this side of the "Maximum number of concurrent connections", if the PC has IIS friends, you can test the above "Limit number of connections" and "maximum number of concurrent connections" settings, are mutually affected. "Maximum concurrent connections" defaults to: 4294967295, which is a staggering number, does this mean that the site can have the ability to execute 4294967295 concurrent connections?

Here are two assumptions:

1, a lot of virtual host vendors said that no concurrent connection limit is really set up?

2, the processing of each connection, IIS will open a thread to handle, assuming this processing mode is set up, then 4,294,967,295 concurrent connection requests come to whether IIS will immediately start 4,294,967,295 threads to process?

for hypothesis 1:It is obviously not true, the maximum number of concurrent connections is set to an absolute limit;

for hypothesis 2: This is a myth for many friends, assuming that 4294967295 concurrent connections come at the same time, IIS does not immediately start 4,294,967,295 threads to process, because this is unrealistic, for the processing of connections, IIS has the "Maximum concurrent worker threads" limit. From some sources, this number is related to the operating system , the value of IIS for the Win7 system is 10 (or otherwise indeterminate), and the value of IIS Express VS2012 comes in is 80. For Windows Server version of the specific value of the system is not clear, that is, 4,294,967,295 concurrent connections came, (this side with Win7 under 10 for example), IIS can only start 10 worker threads in the first time to process, then the other 4294967285 must queue, queued to the user's experience is that the Web page is loading, but nothing is displayed, and then purchased according to the virtual host provider said that the number of non-concurrent connection limit of customers will start to rage, why buy so-called "unlimited concurrent connections", or will always be loaded in the situation, This is the problem with limited IIS processing power.

Of course the server did not return "HTTP Error 503" directly. The service is unavailable. " should also be some of the comfort that you spend more money, because you only purchase the number of IIS connections is 50, then the first 50+1 connection request operation will be directly "HTTP Error 503." The service is unavailable. " The In addition, if the Web server's hardware is sufficient, the worker threads of IIS will also be processed faster, and the user who responds will have to wait a little longer (provided the number of IIS connections is large enough, or 503 directly).

Overall, the maximum number of concurrent connections affects the number of queues , and many times we need to evaluate the maximum number of concurrent connections for our site, and then set the optimal number.

Third. IIS Maximum number of concurrent worker threads

In the above, it is simple to say that IIS in the concurrent connection request when the processing mechanism, it will be more intelligent in a number of units in batch processing, so that no processing connection requests queued, the user's browser in the queue waiting for the response is "loading", which is more than the page directly display "HTTP Error 503. The service is unavailable. " is more acceptable to people. But don't be angry about the refresh button, because the more points you have, the more the request is in the queued queue.

Of course, many friends will say, why I sometimes do not brush the first time, re-brush the content is out,

May be:

1, the page script where to download or handle the problem, causing the page to show abnormal or directly do not display

2, you re-refresh the second level of operation, the Web server faster has been processed by other queues of requests or others have abandoned the Web server connection request operation

3, routing or Broadband network operator problem (unstable)

4, the browser or its own computer problems

I do not know the "maximum number of concurrent worker threads IIS" has no place to set.

Fourth. Queue Length

The maximum number of concurrent connections affects the number of queues, so the setting that further affects the number of queues is the queue length.

Assuming that the maximum number of connections is set to 100,1000 a concurrent connection request comes up, first 900 is returned directly to the customer "HTTP Error 503." The service is unavailable. "

Then IIS starts first (assuming the maximum number of concurrent worker threads is 10) for 10 threads to process the request, and the other 90 into the queued state, if the following actions are done:

application pool → Find the application pool to which the site belongs → right-click Advanced Settings ... → "General" → "Queue Length", set to 20

Then there will only be 20 queued, 70 (20-90 in the queue) will immediately return "HTTP Error 503." The service is unavailable ", the IIS default queue Length setting is 1000, and the range is between 10-65535.

Fifth.maximum number of worker processes

  IIS 6.0 and later allows the application pool to be configured as a Web garden. A single worker process per application pool that can withstand approximately 30-50 or so concurrency.

application pool → Find the application pool to which the site belongs → right-click Advanced Settings ... → "Process Model" → "maximum number of worker processes", the default value is 1.


If this value is greater than 1, then when there is a connection request, multiple new worker process instances are started, the maximum number of processes that can be started, and further requests are sent to the worker process in a circular manner, so that each worker process can assume the load of some connection requests. Of course, the cost of CPU and other hardware, it is worthwhile, if the Web server CPU utilization is very low but also need to more efficient processing of concurrent connection requests, should do so.

If a Web site uses objects such as the session and cache of the dependent process, it cannot be saved in server memory, the storage option StateServer or SQL Server will be better, and multiple worker processes will have context replication when switching, which is also where resources are consumed more.

  1, the maximum working process value of the setting basis

When determining the maximum number of worker processes per application pool, the primary reference data includes the maximum number of concurrent users for the Web site and the number of available memory for the Web server. The maximum number of concurrent users needs to be observed over a period of time, recording the maximum number of concurrent users when the system is busy, and determining the maximum number of worker processes for the application pool according to the principle that each worker process can host 30 concurrency. Also note that each worker process will occupy about 200M of system memory, when setting the maximum number of working processes, the main maximum number of working processes and 200M do not exceed the maximum available memory of the system. In general, it is recommended that the maximum number of working processes be adjusted by the number of 5 work processes each time, after adjusting to the website for a period of time, such as still unable to meet the requirements, and then continue to increase the number of 5 work processes.

  2, session sharing issues

If the site does not use the session mechanism, this issue is not raised. If the session mechanism is used to transmit values and save data, it is necessary to consider session sharing between multiple worker processes in the application pool to prevent the loss of session. The workaround for this issue is shown in the session sharing settings of ASP.

 2.1 Session sharing settings for ASP.

ASP. NET provides the following session save mechanism, as shown in table 1: Session Save method

Mode name

Storage mode

Sex Can


Set to not use session function



Set to store session in process, ASP This is the default value in the storage mode,



is set to store the session in a separate state service. Typically Aspnet_state.exe process

Performance penalty

sqlserver< The/p>

Settings store the session in Sql server.

Performance loss 10-20%


Custom-built storage scheme

determined by implementation

Set the session's Save mode in the Web. config profile of the ASP. If you do not show how the specified session is saved, it is saved by default using InProc, where the session is saved by the worker process that provided the service.

To increase IIS support for high concurrency, you can increase the number of worker processes in an application pool, and IIS dynamically allocates user requests across multiple worker processes based on the built-in scheduling algorithm, and if server clusters and load balancing are set up, user requests are dynamically allocated across multiple worker processes on multiple machines. In the above case, if the session is still saved in InProc, then the user requests to switch between multiple worker processes may occur when the session is lost, resulting in a request failure or error.

To resolve the above, you need to set the session's Save mode to shared, which is the "StateServer", "SQL Server", or "Custom" method in table 1. In these methods, the "SQL Server" approach requires the installation of a separate SQL Server database, "Custom" method needs to implement the corresponding session storage and retrieval process, relatively complex deployment, relative to the above two ways, "StateServer" Approach is best in functionality and implementation, so the following focuses on this session sharing mechanism.

2.2 "StateServer" Setup steps:

[1] Determine the StateServer server. If there is only one Web server, you can specify that the current server is a StateServer server. If there are multiple server clusters, you can specify a lightweight server in the cluster as the StateServer server.

[2] Modify the registry to allow remote access to the StateServer service. You can import the following script directly.

The port defaults to 42424 and can be modified as needed, with 42424 for example below.

[3] Open "Administrative Tools"-"services", find "ASP.", right-click, select "Properties", 4 as shown:

[4] in the pop-up Properties window, change "startup mode" to "Auto", then click "Start" button to start the service, 5:

[5] Open the Web. config profile under the home directory of the site to be modified, search for the "<sessionstate>" Configuration node, and if no configuration node exists, under the <system.web> node, create a new < Sessionstate> "Configure the node and modify the node properties to:
<sessionstate mode= "StateServer" stateconnectionstring= "tcpip="/>
where "tcpip=*" after the host IP address and port can be modified according to the actual situation. Save the configuration file when you are finished modifying it.


[1] Custom objects saved in session must display marked Serializable "[Serializable]". If the mark is not displayed as serializable, an error occurs when the page is accessed.

[2] The StateServer server must be a Windows server operating system, such as Windows Server 2003 or Windows Server 2008.

  3. Reasonable resource recovery mechanism

Most application systems have high working hours, low usage, and should reasonably be released when the system is not busy, so the "limit timeout" and "Recycle interval" properties of the application pool should be set appropriately.

Sixth. Summary

When many requests come at the same time, IIS will determine whether there are extra requests based on the "Maximum number of concurrent connections", the extra request returns 503 directly, and then according to the "Queue Length" to determine if there are any extra requests that cannot be queued, and return 503 directly to the team. So, how to set "Maximum concurrent connections" and "queue Length" is actually a formula that can be calculated:

Maximum concurrent connections = Queue Length + IIS maximum number of concurrent worker threads

The default value of IIS affects the concurrency processing capability of our website:

The default maximum number of concurrent connections for IIS is 4294967295 (more than 4.2 billion), and the queue length default is 1000. For Windows Server versions of IIS, the maximum number of concurrent worker threads may be hundreds of (guess, there may be no limit), and by this default, IIS will handle more than 1000 requests at the same time. More than 1000 this number is the real concurrency capability of IIS, and this ability is not related to our code.

What are the metrics that judge the processing power of our website? Perhaps the most important indicator is the "processing requests per second" (which can be viewed in the Performance Analyzer), which is also known as the throughput rate. If each request is processed very quickly, then the site throughput rate is large, and the throughput rate is large and the number of people online. If you want to do a second kill, it depends on your second kill the relevant URL to support how much throughput.

How does the CPU's computing power affect the processing power of the website? Still so many requests, if the CPU is strong enough to reduce the processing time of each request, it is bound to increase throughput rate. There are many requests, if spend on the network transmission or to the database transfer time is more, this part of the waiting time CPU is idle, if can improve CPU utilization, also may improve the processing ability of the website, the most fully utilize the resources of the server. If you do not want to change the code and want to improve CPU utilization, you can set the maximum number of worker processes in the IIS application pool (the default is 1) and can be set to 10 if the current CPU utilization is only a few percent, adjust this value to pay special attention to each worker process is a standalone application, Global static variables are not shared.

IIS connections, number of concurrent connections, maximum number of concurrent worker threads, queue length, maximum number of worker processes

Alibaba Cloud Hot Products

Elastic Compute Service (ECS) Dedicated Host (DDH) ApsaraDB RDS for MySQL (RDS) ApsaraDB for PolarDB(PolarDB) AnalyticDB for PostgreSQL (ADB for PG)
AnalyticDB for MySQL(ADB for MySQL) Data Transmission Service (DTS) Server Load Balancer (SLB) Global Accelerator (GA) Cloud Enterprise Network (CEN)
Object Storage Service (OSS) Content Delivery Network (CDN) Short Message Service (SMS) Container Service for Kubernetes (ACK) Data Lake Analytics (DLA)

ApsaraDB for Redis (Redis)

ApsaraDB for MongoDB (MongoDB) NAT Gateway VPN Gateway Cloud Firewall
Anti-DDoS Web Application Firewall (WAF) Log Service DataWorks MaxCompute
Elastic MapReduce (EMR) Elasticsearch

Alibaba Cloud Free Trail

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.