In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to identify performance bottlenecks in high-performance ASP.NET sites". The content in this article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to identify performance bottlenecks in high-performance ASP.NET sites.
There are many places that can be optimized on the server side, and there are also many topics of optimization. in this article, we mainly focus on: if we let the server generate the page faster, but also pay attention to if the generated page can reach the client browser faster.
Actually, we're just optimizing the timeline below.
To shorten the above timeline, the server needs to make better use of its resources, such as better use and allocation of memory resources, CPU resources and so on. How to make full use of these resources, to a certain extent, is closely related to the quality of the code we write. A good, efficient code often allows us to spend less money on more hardware devices (so the quality of the code is very important).
Let's take a look at the performance bottlenecks that may occur on the server side:
Insufficient memory
Lack of cach
CPU pressure
Dealing with request thread issues
Next, we will introduce how to use the system's performance diagnosis tools to identify which kind of performance bottleneck causes the server to parse the page too slowly. After finding out the problem with the performance diagnosis tool, then make a detailed analysis of the problem again, and collect data at the same time, according to these data to take corresponding measures to prescribe the right medicine. As for each kind of performance problem how to take measures to solve, our later article will be a chapter in detail, please do not be impatient, here we first learn to find the problem. After discovering that there may be a performance problem with the site, do not immediately modify the site or server, but first diagnose where the bottleneck occurs. J
Memory
The first step is to determine whether the server is out of memory. Because if the memory is insufficient, it will increase the CPU pressure on the server and the IO read and write operations on the disk. In the past, if the problem of lack of memory is solved, the CPU and disk IO read and write operations will naturally be reduced.
Why does lack of memory increase the pressure on CPU and the IO read and write operations of the disk?
When the system is out of memory, the system will transfer some of the data that originally needed to be stored in memory on disk and save it as pagefile.sys. When this data is needed, the system reads and writes the disk. The operation of reading and writing to the disk consumes CPU resources and increases the IO operation of the disk.
Let's take a look at how to identify insufficient memory performance bottlenecks.
We focus on how to diagnose this problem in a Window server system.
Window Server 2003
Enter "perfmon" on the command line of the system. The following window will pop up. Then click the + button above the toolbar, select "Memory" in the "Performance object" drop-down box, and then select the "Pages/sec" counter. If this value is large, it means that CPU is constantly exchanging data between memory and disk.
Windows Vista, Server 2008, Window 7
You can not only run "perfmon" in Windows Vista and Windows Server 2008, but also open the performance monitoring window. And you can run "resmon" to open the resource monitoring window, which is more intuitive from this window. See hard error per second (Hard Faults/sec) in the resource monitoring window. Then check this value for each process, and if the "hard error / second" value of the process is high, then the server is out of memory. We will talk about how to solve this problem in a follow-up article, and here we will first talk about how to find out how to solve this problem.
Caching
As we all know, the appropriate practical caching strategy can greatly improve the performance of the server. We generally cache data in memory, such as the memory of the browser, the memory of the proxy server and so on. And you can cache some commonly used objects, some pages, and even the whole page.
There are many benefits of caching, as follows:
Reduce the response time of the server
Reduce the pressure of using CPU
Avoid frequently reading the database
If you cache the data in a browser or proxy server, you can also reduce unnecessary backhaul.
In general, we cache data that is used frequently or that takes a lot of resources for each generation.
But how can it be regarded as "used frequently"?
There is no certain standard, or the same sentence: it depends! For example, if a page is requested 10 times in 1 second, the request for this page may not be "frequent" compared to other pages (other pages request 100 times in 1 second), but if the page is cached for 1 second, it is also a great improvement in performance, because 90% of requests can be cached within a second. You can take a look at the five-minute rule of caching. As for how to cache, it will be explained in a later article.
CPU
As with previous memory diagnostics, we can run the "perfmon" command and select the "% Processor Time" counter under the "Processor" category. As follows
At the same time, we can run "resmon" to open the "resource monitoring window" to see:
You can see the "CPU" column with a red box, which actually reflects the monitoring result of the "% Processor Time" counter. Generally speaking, if the value of a process is higher than 80%, it means that the process consumes a lot of CPU resources. If the w3wp.exe process consumes 80%, your site consumes a lot of CPU. We will talk about it in a later article: if you reduce the pressure on CPU.
Processing request thread
We know that every request sent to the server is processed by a thread in the application pool. And the number of threads used to process requests is controlled by IIS, and if there are no idle threads in the application pool to process new requests, the request is placed in the request queue to wait. If the request queue on the server side is too long for the server to be busy, the new request is likely to be rejected by the server.
In general, the number of threads available in an application pool is determined by the version of .NET Framework installed by the server and some settings of IIS.
.NET Framework Version
Default number of available threads
1.1.
Number of 20*CPU-8
2.0
12 * number of CPU
3.5, 4.0
IIS 7 Classic Mode: the number of 12 * CPU
IIS 7 integration mode: number of 100 * CPU
If there are not enough threads on the server side to process the request, this situation is called "thread hunger". We can check whether this has happened on the server side of the site through the performance counter of the system:
1. Run "perfmon" in the command window. As follows:
two。 In the performance monitoring window that opens, select performance Monitor, as follows:
3. Click the "+" button and expand the "ASP.NET" category:
4. Add the following counters:
Request Execution Time
Time spent processing a request (in milliseconds)
Request Current
The number of requests to be processed by the ASP.NET runtime now, including the requests being processed and those in the waiting queue.
5. Then expand the "ASP.NET Applications" category and add the following counters:
Request Executing
Number of requests currently being processed
If the number of "Request Current" is greater than the number of Request Executing, then there is a request waiting to be processed. Later articles will describe in detail how to deal with this situation.
If the number of "Request Current" is greater than the number of Request Executing, then there is a request waiting to be processed. Later articles will describe in detail how to deal with this situation.
Thank you for reading, the above is the content of "how to identify performance bottlenecks in high-performance ASP.NET sites". After the study of this article, I believe you have a deeper understanding of how to identify performance bottlenecks in high-performance ASP.NET sites. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 223
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.