IIS application pool multi-Worker Process settings and Session sharing

Source: Internet
Author: User

When tuning iis, I would like to share with you a great setup step. Thank you for sharing it with me.

IIS application pool multi-Worker Process settings and Session sharing

1 Overview

Microsoft's IIS is Asp on Windows. the default WEB server released by the. Net Website provides high flexibility and scalability in terms of performance. You can set the number of worker processes in the application pool, supports tens to tens of thousands of concurrent accesses. This document provides operation instructions for the corresponding setup process and describes the precautions during the setup process.

2. Application pool multi-Worker Process settings

Based on past experience, in the mainstream PC-SERVER host (Xeon E5645 @ 2.4 GHz, 6 Core 12 thread, 32 GB memory), each application pool of a single working process, it can withstand about 30-50 concurrent requests. If the number of concurrent requests exceeds this limit, IIS may fail to respond, or the response time may be significantly longer. Setting the maximum number of working processes in the application pool can significantly improve IIS's ability to cope with high concurrency and reduce website response time.

2.1 setup steps

1. Find the application pool corresponding to the website to be set, as shown in Figure 1:

Figure 1 locate the application pool

2. Right-click the selected application pool and choose advanced settings, as shown in figure 2:

Figure 2 Advanced Settings

3. In the advanced settings window that appears, locate the maximum number of working processes and set it to a reasonable value, as shown in Figure 3:

Figure 3 set the maximum number of worker Processes

4. Click OK to save the settings.

2.2 precautions

1. Set the maximum number of worker Processes

When determining the maximum number of worker processes in each application pool, the most important reference data includes the maximum number of concurrent users of the website and the number of available memory of the Web server. The maximum number of concurrent users must be observed for a period of time to record the maximum number of concurrent users when the system is busy, determine the maximum number of worker processes in the application pool based on the principle that each worker process can carry 30 concurrent tasks. Note that each worker process occupies about MB of system memory. When setting the maximum number of worker processes, the product of the maximum number of worker processes and the maximum number of available memory of the system must not exceed the maximum number. Generally, we recommend that you adjust the maximum number of worker processes by increasing the number of five worker processes each time. After the adjustment, observe the website for a period of time. If the requirements still cannot be met, then, increase the number of worker processes.

2. Session sharing

If the website does not use the session mechanism, this issue will not occur. If the session mechanism is used to transmit values and store data, you need to consider sharing sessions among multiple worker processes in the application pool to prevent session loss. For solutions to this problem, see session sharing settings.

3. Reasonable Resource Recovery Mechanism

Most application systems have high work time usage and low non-work time usage. In this case, operating system resources should be reasonably released when the system is not busy. Therefore, the [Restriction timeout] and [recycle interval] attributes of the application pool should be reasonably set.

3 Asp. Net Session sharing settings

ASP. NET provides the following session storage mechanisms, as shown in table 1:

Table 1 session Storage Method

Method Name

Storage Method

Performance

Off

Set to not use the Session Function

None

InProc

Set to store sessions in the process, that is, the storage method in ASP. This is the default value.

Highest

StateServer

Set to store sessions in independent State services. Usually the aspnet_state.exe Process

Performance Loss: 10-15%

SQLServer

Set to store sessions in SQL Server.

Performance Loss: 10-20%

Custom

Custom Storage Solution

Determined by the implementation method

Set the session storage mode in the web. config configuration file of the ASP. NET program. If the storage mode of the specified session is not displayed, inproc is used by default to save the session, that is, the session is saved by the working process that provides the service.

To improve IIS support for high concurrency, you can increase the number of worker processes in the application pool. IIS dynamically allocates user requests among multiple worker processes based on the built-in scheduling algorithm, if a server cluster and Server Load balancer are set up, user requests are dynamically allocated among multiple worker processes on multiple machines. Under the above circumstances, if the Session is still saved as InProc, Session loss may occur when the user request is switched between multiple working processes, resulting in request failure or error.

To solve this problem, you need to set the Session storage method to share, that is, the "StateServer", "SQLServer", or "Custom" methods in table 1. In these methods, the "SQLServer" method requires the installation of an independent SQLServer database, and the "Custom" method requires the implementation of the corresponding Session storage and retrieval process, which is relatively complicated to deploy, compared with the above two methods, the "StateServer" method is the best in terms of functionality and implementation. Therefore, we will focus on this Session sharing mechanism.

3.1 setup steps

1. Confirm the StateServer server. If you only have one WEB server, you can specify the current server as the StateServer server. If multiple server clusters exist, you can specify a server in the cluster that conforms to the lighter server as the StateServer server.

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

The default port is 42424, which can be modified as needed. The following uses 42424 as an example.

3. Choose Administrative Tools> services, find Asp. Net State Service, right-click and choose Properties, as shown in figure 4:

Figure 4 Asp. Net State Service

In the displayed Properties window, change "start mode" to "automatic", and click "start" to start the service, as shown in Figure 5:

Figure 5 start a service

4. Open the web under the Home Directory of the website to be modified. in the config file, find the "<sessionstate>" configuration node in the search. If no configuration node exists. web> "Create a" <sessionstate> "configuration node under the node, and modify the node attribute:
<Sessionstatus mode = "StateServer" stateConnectionString = "tcpip = 127.0.0.1: 42424"/>
The Host IP address and port after "tcpip = *" can be modified according to the actual situation. After modification, save the configuration file.

3.2 precautions

1. The custom object stored in the Session must be marked as serializable. If it is not displayed as serialized, an error is reported when accessing the page.

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

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.