What is the maximum number of concurrent IIS requests on your server?

Source: Internet
Author: User

Test System: Window 2003 Server, IIS 6.0, ASP. Net 3.5 sp1
Dual 1.8 Dual-core, 2 GB memory, and 14 GB virtual memory.
To explore the maximum number of concurrent IIS jobs, we need to make several assumptions.
1. Assume that the maximum number of concurrent connections is the current number of connections. This means that the current connection can withstand the maximum, so it indicates the maximum concurrency.
2. If the IIS application pool is in the default state, changing the settings will affect the maximum number of connections.
Now, let's make the following assumptions: Set the site to maintain the HTTP connection and set the timeout value to 0, that is, the site will not time out. Set Thread. Sleep (int. MaxValue) on the default. aspx page of the site request, and then develop a small program to keep the connection. Copy codeThe Code is as follows: class Program {
Private volatile static int errorCount = 0;
Private volatile static int rightCount = 0;
Static void Main (string [] args ){
ServicePointManager. DefaultConnectionLimit = 10000;
Int count = 0;
Int all = 0;
While (true ){
All ++; count ++;
CreateThread ();
Thread. Sleep (10 );
If (count >=200 ){
Console. WriteLine (string. Format ("sucess: {0}; error: {1}", all-errorCount, errorCount ));
Count = 0;
}
If (all-1800)
Break;
}
Console. ReadKey ();
}
Static void CreateThread (){
Thread thread = new Thread (ActiveRequest );
Thread. IsBackground = true;
Thread. Start ();
}
Static void ActiveRequest (){
RequestClient client = new RequestClient ("http: // 192.168.18.2/default. aspx? D = "+ Guid. NewGuid ());
Client. RequestProcess ();
If (client. IsError ){
ErrorCount ++;
Console. WriteLine (string. Format ("error message: {0}", client. Messages ));
} Else {
RightCount ++;
// Console. WriteLine (client. Messages );
}
}
}

Using System;
Using System. Collections. Generic;
Using System. Text;
Using System. Net;
Using System. IO;
Namespace MaxLinked {
/// <Summary>
///
/// </Summary>
Public class RequestClient {
HttpWebRequest request;
WebResponse response;
Public RequestClient (string url ){
Request = (HttpWebRequest) HttpWebRequest. Create (url );
Request. Timeout = int. MaxValue;
Request. KeepAlive = true;
ErrorCode =-1;
}
Public void AddHeader (string name, string value ){
Request. Headers. Add (name, value );
}
Private bool isError = false;
Private StringBuilder buffer = new StringBuilder ();
Public int ErrorCode {get; set ;}
Public bool IsError {
Get {return isError ;}
}
Public string Messages {
Get {return buffer. ToString ();}
}
Public void RequestProcess (){
Try {
Response = request. GetResponse ();
} Catch (WebException ex ){
ErrorCode = (int) ex. Status;
Buffer. Append (ex. Message );
IsError = true;
}
If (response! = Null ){
Stream stream = null;
StreamReader reader = null;
Try {
// Stream = response. GetResponseStream ();
// Reader = new StreamReader (stream, Encoding. UTF8 );
// Buffer. Append (reader. ReadToEnd ());
} Catch (Exception ex ){
Buffer. Append (ex. Message );
IsError = true;
} Finally {
// If (reader! = Null)
// Reader. Close ();
// If (stream! = Null)
// Stream. Close ();
}
} Else {
IsError = true;
Buffer. Append ("connection establishment failed! ");
}
}
Public void Close (){
If (response! = Null)
Response. Close ();
Request. Abort ();
}
}
}

The program is set to start only 1800 threads. This is because the maximum number of threads in A. Net Single process seems to be 2000. Therefore, to test the maximum number of concurrent tasks, you must start several testing processes at the same time. When the system virtual memory is adjusted to the maximum value, too many threads will greatly occupy the memory. Test now.
Open the performance counter of the web site and adjust the display ratio to 10 thousand.
When 5000 connections are found, the IIS server crashes (503 error) and takes a bath. the IIS server cannot fix the error by itself. After several tests, we found that the maximum number of concurrent tasks is 8200, but it usually crashes around 5000, sometimes only 1000.
By 8200, a user opens a browser to browse the Web page, which may occupy 2 ~ Three connections are calculated by two. By default, the maximum number of concurrent connections in IIS is about 4000.
Open the application pool configuration and increase the maximum number of working processes (1 by default) to effectively increase the maximum number of connections. I remember I have read an article about it. It is appropriate to adjust it to around 5.

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.