当前位置: 首页 > 图文教程 > 服务器 > Windows服务器 > 你的服务器IIS最大并发数有多少?

Windows服务器
windows2003 apache配置虚拟主机和绑定域名服务
使用svn进行版本控制
VisualSVN Server的配置和使用方法 图文
http ftp错误代码整理说明
Windows 安装IIS出现的问题(无法安装IIS,提示“安装程序无法复制文件IISApp.vbs”)
比较详细的iisapp使用实例代码
怎样通过iisapp命令查找pid来解决IIS的cpu占用率过高问题
2009年最新版 win2003 IIS6+PHP5+MySQL5+Zend Optimizer+phpMyAdmin安装配置教程
win2003 IIS+MySQL服务管理助手
windows服务器 的DNS服务器备份与还原步骤小结
IIS 应用程序保护级别说明
win2003 PHP服务器的突破新思路
IIS 服务器备份转移实现方法
Win2008 iis7服务器中批量迁移到另外一台IIS7的实现步骤
IIS 服务器的备份和移植技巧
IIS备份 自动备份IIS设置和恢复IIS设置(自动还原Web服务器)
备份、还原IIS网站配置信息
IIS备份 恢复一键搞定
启用IIS6的GZIP功能,提高网站打开速度,减少带宽占用
服务器 UDP端口占用几千个的解决办法

Windows服务器 中的 你的服务器IIS最大并发数有多少?


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-04   浏览: 79 ::
收藏到网摘: n/a

做完假设,现在做限制,设置站点保持HTTP连接,超时设置成0,就是不会超时。在站点请求的default.aspx页面设置线程Thread.Sleep(int.MaxValue),接下来开发一个用来保持连接的小程序。 测试系统Window 2003 Server ,IIS 6.0 ,ASP.Net 3.5 sp1
Dual 1.8双核,2G内存,14G虚拟内存。
为了探寻IIS的最大并发数,先要做几个假设。
1、假设最大并发数就是当前的连接数。意思是当前能承受最大的连接,那么就表明最大的并发。
2、假设IIS应用程序池处于默认状态,更改设置将会对最大连接数产生影响。
做完假设,现在做限制,设置站点保持HTTP连接,超时设置成0,就是不会超时。在站点请求的default.aspx页面设置线程Thread.Sleep(int.MaxValue),接下来开发一个用来保持连接的小程序。
复制代码 代码如下:

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("错误消息:{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("建立连接失败!");
}
}
public void Close() {
if (response != null)
response.Close();
request.Abort();
}
}
}

程序设置为只能启动1800个线程,这是由于.Net单进程最大线程数好像是2000个。因此,要测试最大并发数,要需要同时开几个测试进程。把系统虚拟内存调到最大值,线程过多会急剧占用内存。现在开始测试。
打开web站点的性能计数器,把显示比例调成1万。
发现到5000个连接时,IIS服务器崩溃(503错误),去洗了个澡,发现IIS服务器无法自己修复错误。又测试了几次,发现最大并发值是8200个,但是一般到5000左右就会崩溃,有时候甚至只有1000个。
按8200个计算,一个用户开一个浏览器浏览网页,可能会占用2~3个连接,按两个计算,那么IIS默认情况下,最大并发数是4000个左右。
打开应用程序池配置,把最大工作进程数调高(默认为1),能有效提高最大连接数。我记得以前看过一篇文章,讲的是调到5左右比较合适。