Build a high-performance. NET application to configure a high-availability IIS server-Article 5 common IIS problems: Working Process recycling mechanism (medium)

Source: Internet
Author: User

 

In this article, we will go on to talk about the "working process recycling mechanism ".

This articleArticleThe topics are as follows:

Explanation of Working Process recycling mechanism

Time-based recovery mechanism

Recovery mechanism based on the number of requests

Memory-based recovery mechanism

Activity status-based recovery mechanism

 

Series of articles:

Configuration of high-availability IIS server for building high-performance. Net Applications-Article 1: required knowledge of IIS 

Build a high-performance. NET application configuration high-availability IIS server-Part 2 IIS Request Processing Model Configuration of high-availability IIS server for building high-performance. Net Applications-Part 3 Explanation of the three core components of IIS (Part 1) Configuration of high-performance. Net Applications-Part 3 Explanation of three core components of IIS (part 3) Build a high-performance. NET application to configure a high-availability IIS server-Article 4 common IIS problems: Working Process recycling mechanism (I)

Recovery mechanism based on the number of requests

This mechanism based on the number of requests is very understandable: when our applicationProgramAfter the number of requests received reaches a threshold value, the resources used by the worker process in the application pool are recycled. The time-based setting method is similar to that described earlier,

 

In fact, in many cases, the reason for this mechanism is that the application has been unable to process too many requests, resulting in request processing failure, and has to start running this mechanism.

 

Memory-based recovery mechanism

The collection of application pool can be set through the memory it uses. You can decide when to recycle by setting the memory it uses and its virtual memory, the general situation is as follows:

 

 

We use the memory-based Working Process reclaim mechanism to prevent memory leakage or excessive memory allocation to a certain extent. At the same time, it should be clear that, in many cases, the performance of our web applications depends on the cache to a large extent, especially in ASP. when using its cache API in. net, we need to be very clear about these issues. The size of the cached data space is not unlimited, and its size can be configured. It is possible that the data enters the cache in the first second, the cached data will be lost in the next second, which may cause the "object not found" problem. At this time, the reason is that the size of the cache space has reached the set value, leading to the collection of work processes, so that all data is lost. For more information about this aspect, refer to my other article: 9 main mistakes in Using Cache (I)

 

In addition, setting a memory-based recycle mechanism can enable the recycle mechanism to "Monitor" the memory and prevent memory leakage.

After talking about this, let's take a look at how to set a memory-based recovery mechanism.

 

Private memory usage (Private bytes) 

This setting can limit the size of dedicated non-shared memory that can be used before a worker process is recycled. As a matter of fact, it is estimated that some friends may not understand it again, because it involves some knowledge about window memory management. You can refer to this article: Windows Memory Management knowledge popularization.

Note: it can be said that Windows Memory, process scheduling, and other knowledge are the foundation to be mastered in the performance optimization process. In fact, many developers do not understand these things, but only understand the C # syntax, then use the basic syntax to program the program. If this is the case, it is difficult to improve the technology to a very high level.

 

In IIS6, this setting is called the "maximum memory used" in the "recycle" option of the application's "attribute". The unit is MB, as shown below:

 

 

In iis7, it is called "dedicated memory" (in fact, it is also the amount of memory available in kernel mode), measured in KB.

Setting of this value is critical to the cache and session usage in ASP. NET applications. If this value is set too small and our application is very dependent on the cache, it will cause frequent collection of work processes, A lot of data stored in the process will be lost, and the consequences can be imagined.

 

After ASP. net2.0, the cache mechanism uses a cache pruning policy to prevent the workflow from being recycled. What does it mean?

 

That is, the cache mechanism is based on some policies (for example, the minimum number of recently usedAlgorithm) To remove some data in the cache and give the idle location to other data, so as to avoid excessive use of the cache space, so as to avoid too much memory usage and reach the recovery threshold. We can use privatebyteslimit settings in Web. config to configure the cache cropping level, as shown below:

 

 

Next, let's take a look at when cache pruning occurs by default:

User Mode memory size

<= 2 GB

> 2 GB (32-bit operating system)

> 2 GB (64-bit operating system)

60% * physical memory or 800 mb

60% * physical memory or 800 mb

60% * physical memory or 1 Tb

 

The above table is relatively simple. Here I will just explain it a little bit (for example, the user mode memory is smaller than 2 GB): If the user mode of the process in the operating system memory is less than 2 GB, the value of privatebyteslimit will be: 60% * physical memory (for example, the size of the memory we configured is 4 GB). If the size of the configured physical memory is too small, for example, 1 GB, 60% * 1 GB = 600 mb. At this time, privatebyteslimit does not set the value according to this, but takes 800 mb directly.

 

In addition to setting the fixed value of privatebyteslimit, we can also set it according to the ratio. We can use percentagephysicalmemoryusedlimit to set the cache process to be cropped after the memory usage. This is a dynamic process, it can be calculated by itself. In addition, this value can effectively reduce the operation of the. NET garbage collection mechanism and improve performance.

Virtual memory usage (Virtual bytes)

Here, I don't need to introduce the concept of virtual memory. The problem of virtual memory is also very difficult to diagnose and discover. The problem of virtual memory is mainly the problem of fragmentation.

When a process is running, it consists of the maximum virtual memory size. For example, in the Win32 operating system, it is 4 GB, the user mode and kernel mode are 2 GB (when/3GP is not used ). When the program in the process requires memory, the Virtual Memory Manager allocates a space. Over time, the virtual memory may produce a lot of fragments, leading to the failure of subsequent memory allocation, the "out of memory" issue occurs.

 

In fact, we do not have a very good way to avoid this problem, but we can use some experience to ease it. For example, we can set to start recycling when the virtual memory space uses 70%, at the same time, we can also analyze data by monitoring the performance speedometer process/virtual bytes.

 

 

 

 

 

Links to articles:

Detailed explanation of IIS Server Load balancer-application request route Article 1: arr Introduction

Detailed explanation of IIS Server Load balancer-application request route Article 2: Create and configure Server Farm

IIS Server Load balancer-application request route explanation Article 3: Server Load balancer for HTTP requests using Arr (I)

IIS Server Load balancer-application request route explanation Article 3: Server Load balancer for HTTP requests using Arr (below)

Detailed description of IIS Server Load balancer-application request route Article 4: layer-3 deployment architecture using arr

 

Server Load balancer Principles and Practices: Part 1 (reorganizing)

Server Load balancer Principles and Practices)

Server Load balancer principles and practices part 3 basic concepts of Server Load balancer-network Basics

Server Load balancer principles and practices Chapter 4 Server Load balancer Clusters

Principles and Practices of Server Load balancer Article 5 Detailed description of data packet process during Server Load balancer

Server Load balancer principles and practices Chapter 6 Health Check Mechanism (part I)

Server Load balancer principles and practices Chapter 7 Health Check Mechanism (II)

Server Load balancer principles and practices Chapter 8 Network Address Translation (part I)

Server Load balancer principles and practices Chapter 8 Network Address Translation (Part II)

Server Load balancer principles and practices Article 9 Server Load balancer advanced technology-session persistence (I)

Server Load balancer principles and practices Article 10 Server Load balancer advanced technology-session persistence (medium) Server Load balancer principles and practices 11th Server Load balancer advanced technology-session persistence (below): delayed binding

 

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.