IIS Performance Diagnosis and Optimization

Source: Internet
Author: User
Tags metabase

1. Enable content expiration
Enabling content expiration for static files improves access performance. First, the website directory should be reasonably divided, and images, CSS, and JavaScript should be placed in a separate directory. Then, in IIS, select the directory, click Properties-HTTP header, and enable content expiration, you can select 30 days later. In this way, your browser compares the current date with the end date to determine whether to display the cache page or the page requested to be updated from the server, because images, CSS, and JS are usually less changed, they are basically read from the local cache to speed up display.

The optimization results cannot be tested in LoadRunner. Some browser settings in run-time settings will affect the test results:
Check for newer versions of stored pages every visit to the page
Download non-HTML Resources
Simulate a new user on each iteration
Clear cache on each iteration

0.049 vs. 0.253

This error occurs when 300 concurrency in controller:
Error: communication error: linked list client failed to initialize server pointer.

 

 

Ii. Enable gzip Compression
HTTP compression is used to transfer compressed text content between web servers and browsers. HTTP compression uses common compression algorithms such as gzip to compress HTML, JavaScript, or CSS files. The biggest advantage of compression is that it reduces the amount of data transmitted over the network and increases the access speed of the client browser.
To use this function, right-click "website"> "properties" and select "service ". Select "compressed static files" in the "HTTP compression" box. We recommend that you set a directory for another disk separately.
Then, in IIS manager, right-click "Web Service extension"-> "Add a new Web Service extension", and enter "httpcompression" in "extension ", add "required file" to c: \ windows \ system32 \ inetsrv \ gzip. DLL, the Windows System directory may vary depending on your installation, select "set extension status to allow ".
Finally, Open c: \ windows \ system32 \ inetsrv \ metabase in the text editor. XML: add the extension name of the static file to be compressed in hcfileextensions. The default value is HTML and TXT files. We recommend that you add JavaScript and CSS files instead of compressed files such as images or ZIP files.

Lab:
Stop IIS:
Iisreset-stop

Set IIS
Modify the metabase. xml file:
<Iiscompressionscheme location = "/lm/w3svc/filters/compression/deflate"
Hccompressiondll = "% WINDIR % \ system32 \ inetsrv \ gzip. dll"
Hccreateflags = "0"
Hcdodynamiccompression = "true"
Hcdoondemandcompression = "true"
Hcdostaticcompression = "true"
Hcdynamiccompressionlevel = "10"
Hcfileextensions = "htm
Html
JS
CSS
GIF
PNG
JPG
TXT"
Hcondemandcomplevel = "10"
Hcpriority = "1"
Hcscriptfileextensions = "ASP
DLL
EXE
Aspx
Ashx"
>
</Iiscompressionscheme>
<Iiscompressionscheme location = "/lm/w3svc/filters/compression/gzip"
Hccompressiondll = "% WINDIR % \ system32 \ inetsrv \ gzip. dll"
Hccreateflags = "1"
Hcdodynamiccompression = "true"
Hcdoondemandcompression = "true"
Hcdostaticcompression = "true"
Hcdynamiccompressionlevel = "10"
Hcfileextensions = "htm
Html
JS
CSS
GIF
Txt
JS
CSS
PNG
GIF
Jpg"
Hcondemandcomplevel = "10"
Hcpriority = "1"
Hcscriptfileextensions = "ASP
DLL
EXE
Aspx
Ashx"
>
</Iiscompressionscheme>
<Iiscompressionschemes location = "/lm/w3svc/filters/compression/parameters"
Hccachecontrolheader = "Max-age = 86400"
Hccompressionbuffersize = "8192"
Hccompressiondirectory = "E: \ iistemp"
Hcdodiskspacelimiting = "false"
Hcdodynamiccompression = "true"
Hcdoondemandcompression = "true"
Hcdostaticcompression = "true"
Hcexpiresheader = "wed, 01 Jan 1997 12:00:00 GMT"
Hcfilesdeletedperdiskfree = "256"
Hciobuffersize = "8192"
Hcmaxdiskspaceusage = "99614720"
Hcmaxqueuelength = "1000"
Hcminfilesizeforcomp = "0"
Hcnocompressionforhttp10 = "true"
Hcnocompressionforproxies = "true"
Hcnocompressionforrange = "false"
Hcsendcacheheaders = "false"
>
</Iiscompressionschemes>

Start IIS
Iisreset-start

To set the run-time settings of LoadRunner, select the following options:
Download non-HTML Resources
Simulate a new user on each iteration (clear cache on each iteration)

Comparison of the LR test results before and after gzip compression Optimization
Before setting:
Successful transactions: 22642
Average throughput: 11861865.760
Average CTR: 4987.111
Average Transaction Response Time: 0.264
After setting:
Successful transactions: 10095
Average throughput: 2817851.889
Average CTR: 2198.889
Average Transaction Response Time: 0.592
As you can see, HTTP compression is set to reduce the performance by about half.
By comparing the resource usage, we can see that the CPU usage is slightly higher when compression is adopted, which may cause the IIS server to slow down the response:
Do not use compression:
Processor time: 97.906
Processor queue length: 11.75
Compression:
Processor time: 98.372
Processor queue length: 14.75

* Note: The test machine and press are on the same machine.

Test the larger image (104 K) request. We can see that the performance is still better without compression:
Compression:
Successful transactions: 43024
Average throughput: 60460790.460
Average CTR: 570.211
Average Transaction Response Time: 0.129
Do not use compression:
Successful transactions: 63030
Average throughput: 92320831.250
Average CTR: 859.903
Average Transaction Response Time: 0.088

For testing larger image (1517 K) requests, we can see that the performance is still better without compression:
Compression:
Successful transactions: 4842
Average throughput: 87505641.380
Average CTR: 61.800
Average Transaction Response Time: 1.198
Do not use compression:
Successful transactions: 7052
Average throughput: 141753682.700
Average CTR: 92.595
Average Transaction Response Time: 0.807

For testing larger image (1517 K) requests, we can see that the performance is still better without compression:
Compression:
Successful transactions: 817
Average throughput: 95983534.770
Average CTR: 7.910
Average Transaction Response Time: 9.565
Do not use compression:
Successful transactions: 1093
Average throughput: 142537464.000
Average CTR: 11.613
Average Transaction Response Time: 6.534

It is estimated that the compression ratio of these images is not large enough. Try another document. The compression ratio is 10146 kb before compression and 3366 kb after compression.
Compression:
Successful transactions: 1331
Average throughput: 60524439.910
Average CTR: 13.910
Average Transaction Response Time: 5.057
Do not use compression:
Successful transactions: 1311
Average throughput: 151881857.100
Average CTR: 14.618
Average Transaction Response Time: 5.185

According to tools such as yslow and httpwatch, The downloading speed is much higher after compression.
It can be seen that for websites with low compression ratios, using HTTP compression may not bring too much optimization effect. If the CPU is a bottleneck, it will reduce the performance.

* How HTTP compression works
1. After receiving the HTTP request from the browser, the web server checks whether the browser supports HTTP compression;
The "Accept-encoding: gzip, deflate" parameter in the HTTP header of the request sent by the browser indicates that the gzip and deflate compression algorithms are supported.
2. If the browser supports HTTP compression, the web server checks the suffix of the request file;
To start static files and dynamic file suffixes, you must set them in metabase. xml.
Static files need to be set: hcfileextensions metabase property (click to jump to the msdn instructions)
Dynamic file needs to be set: hcscriptfileextensions metabase property (click to jump to the msdn instructions)
3. If the requested file is a static file such as HTML and CSS, and the file suffix is compressed, the web server will check whether the latest compressed file of the requested file already exists in the compression buffer directory;
4. If the compressed file of the request file does not exist, the web server returns the uncompressed request file to the browser and stores the compressed file of the request file in the compressed buffer directory;
5. If the latest compressed file of the request file already exists, the compressed file of the request file will be directly returned;
6. If the requested file is a dynamic file such as aspx and the file suffix is compressed, the web server dynamically compresses the content and returns it to the browser. The compressed content is not stored in the compressed cache directory.

Refer:
Http://www.cnblogs.com/zhangziqiu/archive/2009/05/17/gzip.html

 

3. Configure the application pool queue length limit
The application pool queue length limit prevents a large number of requests from waiting in queue, resulting in server overload. When the application pool queue length limit is enabled, IIS monitors the number of requests in the specified application pool queue before adding new requests to the queue. If the size limit of the queue is exceeded when a new request is added to the queue, the server rejects the request and sends a 503 Error Response to the client (the response cannot be customized ). However, even if you change the queue length limit to a value smaller than the current queue length, existing requests in the queue will remain in the queue.
Change the application pool queue length limit:
In IIS manager, expand the Local Computer, expand the application pool folder, right-click the application, and then click Properties ".
Click the performance tab.
In the "Request queue limit" section, select the "core Request queue limit as" check box, and click the up and down arrows in the "request count" box to set the maximum number of requests in the queue.
Click application, and then click OK ".
Note that if the "limit to core Request queue" check box is not selected, IIS will not execute the queue limit. Because the number of requests in the queue is not limited, IIS may add requests to the queue until the server's memory is exhausted.

If the queue length is relatively low, LoadRunner will receive the 503 error when simulating a large number of concurrent requests:
Action. C (4): Error-26609: HTTP status-code = 503 (Service unavailable) for "http: // localhost/storecsvs /"

 

Iv. Set the number of website connections
You can configure Internet Information Service (IIS) to allow unrestricted concurrent connections or limit the number of connections received by the website. If the connection tends to fluctuate, set the number to unrestricted to avoid constant management. However, if the number of connections exceeds system resources, the system performance may be affected. Limiting the number of connections on a site can ensure stable performance. The settings are site-specific and can be adjusted as the network traffic and usage change.

When the number of virtual users in LoadRunner is greater than the number of connections set by IIS, the system will receive the 503 error:
Action. C (4): Error-26609: HTTP status-code = 503 (Service unavailable) for "http: // localhost/storecsvs /"

View the window system log:
The application pool 'defaultapppool 'exceeds its job limit settings.

 

5. Enable CPU monitoring
CPU monitoring is a tool that monitors and automatically disables worker processes that consume a large amount of CPU time. CPU monitoring is enabled for a single application pool. The administrator can set two types of CPU monitoring operations for the application pool.
1. error event logging: When the CPU usage of a specific application pool or application pool group reaches the set limit, IIS records an error in the Windows event log. The error contains the name of the specific Worker Process and the application pool that exceeds the CPU limit. When you use IIS manager to enable CPU monitoring, this will be displayed as "no operation ".
2. Stop the problematic application: After IIS writes errors to the Windows event log, it will send the shutdowntimelimit setting of the application pool to each worker process and then close the command, start to close all worker processes in the application pool. If the process is not closed after the time, as long as IIS is not configured to replace the working process or the working process is not configured for debugging, IIS terminates the working process. The application pool is closed and will be closed until the cpuresetinterval Time Window expires. Once the cpuresetinterval Time Window expires, the application pool restarts. When you use IIS manager to enable CPU monitoring, this will be displayed as "off ".
Enable CPU monitoring:
In IIS manager, expand the Local Computer, expand the application pool folder, right-click the application pool to enable CPU accounting, and then click Properties ".
Click the performance tab and select the Enable CPU monitoring check box.
In the "Maximum CPU usage" check box, click the up and down arrows to set the maximum percentage of CPU used by the application pool. If the CPU usage of the application pool exceeds the specified maximum limit, IIS generates an error message in the Windows event log.
In the "Refresh CPU usage value (minutes)" box, click the up and down arrows to set the refresh rate.
In the "actions performed when the CPU usage exceeds the maximum usage" list box, select the required action for the specified application pool. Click "no operation" to generate an error message in the Windows event log When IIS reaches the maximum CPU usage limit in the specified application pool. Click Close to close the entire application pool. Click Close to terminate the problematic application by ending the main workflow.
Click application, and then click OK ".

 

6. Configure web Parks
You can use IIS 6.0 Working Process Isolation Mode to configure the application pool to be supported by multiple working processes. The application pool that uses multiple working processes is called "Web Garden ". The difference between the Web Garden and the Web farm is that the Web garden uses multiple working processes for an application pool, while the Web farm uses multiple servers for a website.
Creating a web garden for an application pool improves performance in the following aspects:
Reliable request processing: when a worker process in the application pool stops processing (for example, when the script engine stops responding ), other worker processes can accept and process requests from the application pool.
Reduced resource contention: when the web garden reaches a stable state, each new TCP/IP connection will be allocated to a worker process in the Web garden according to the loop scheme. This can balance the workload and reduce the resource contention of the bound worker process.
Configure the Web Garden:
In IIS manager, expand local computer, expand application pool, right-click the application pool, and then click Properties ".
Click the performance tab, and in the "Maximum number of worker processes" box under "Web Garden", type the number of worker processes to be specified to the application pool.
Click OK ".
* If the value is greater than 1, the data cache may not be synchronized between multiple processes.

 

 

Refer:
IIS6 Optimization Based on yslow optimization policy
Http://www.nnwb.com.cn/yahoo-optimization/2009430323.htm
Performance testing Microsoft. NET web applications learning notes
Http://www.docin.com/p-98321621.html

 

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.