. Net Core memory recovery mode and performance test comparison and analysis, core comparison and analysis

Source: Internet
Author: User

. Net Core memory recovery mode and performance test comparison and analysis, core comparison and analysis

. NET Core two GC modes:

Server GC/Workstation GC

Server GC:

It is mainly used in multi-processor systems and serves as the default configuration of the ASP. NET Core host. It creates a GC Heap for each processor and executes the recycle operation in parallel. GC in this mode can maximize throughput and better shrinkage. This mode features a large initial memory allocation and does not recycle the memory as much as possible. It takes a long time to recycle the memory and fragment the memory. In a simple sentence, this is the greedy mode, which achieves better performance by obtaining as much memory as possible and with less recycle. The result is high memory usage and good performance.

Workstation GC:

It is mainly used in single-processor systems. Workstation GC can improve performance by reducing the number of program pauses during garbage collection. Applications that are low-load and not often run tasks in the background (such as services) can use workstation garbage collection when concurrent garbage collection is disabled. It is characterized by frequent recovery to prevent a long period of recovery. The result is that the performance of low memory usage is poor.

Simple Test

The following test results are all on the same computer. The configuration is as follows:

• Windows 7 Ultimate

• Intel Core I3-3220 @ 3.30 GHZ

• 8 GB memory, 3 GB available space

• SQL Server 2014

The program to be tested is ZKEACMS, home page, single-sided stress test, 5000 requests, and 1000 concurrency. The test results are as follows:

Server GC:

The response result is as follows, which is about 167.81 Req/s. This result is not the same every time and may be biased for reference only:


The memory usage has risen to about 600 mb, during which the ups and downs will fluctuate, as shown in:


After repeated tests, the maximum memory size increases to more than 800 mb, which is related to the available memory.More available memory, Will rise to 1 GB or higher and thenDrop againCome:


Workstation GC:

As shown in the response result, about 151.33 Req/s seems to be a little worse than the Server GC, and the overall results of Multiple tests are worse.


The memory usage has been around MB, and repeated stress tests won't make a big difference, which is related to its active recovery:


Switching of memory recovery mode

Now I have some knowledge about the impact of different memory recycling modes of. Net Core. You can make a choice based on your personal situation .. The default greedy mode of Net Core can achieve better performance. There is no problem because it is a waste of memory. Of course, if many programs on your server are running and you have high requirements on memory and do not affect other programs, you need to make some configuration.

Development Environment

In the development environment, you can edit your project file and add the following configuration to regenerate it:

<PropertyGroup> 
 <ServerGarbageCollection>false</ServerGarbageCollection> 
</PropertyGroup>

Production Environment

You do not need to modify the redeployment and go directly to your program to find *. runtimeconfig. json, such as ZKEACMS. webHost. runtimeconfig. json, modify "System. GC. server ": false. Restart the program:

"configProperties": {
 "System.GC.Server": false
 }

References: https://docs.microsoft.com/en-us/dotnet/standard/garbage-collection/fundamentals

The above. Net Core memory recovery mode and performance test comparison analysis are all the content shared by Alibaba Cloud. I hope you can give us a reference and support for the customer.


Related Article

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.