多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

國內(nèi)最全I(xiàn)T社區(qū)平臺 聯(lián)系我們 | 收藏本站
阿里云優(yōu)惠2
您當(dāng)前位置:首頁 > 服務(wù)器 > Windows實(shí)戰(zhàn):探尋IIS最大并發(fā)數(shù)

Windows實(shí)戰(zhàn):探尋IIS最大并發(fā)數(shù)

來源:程序員人生   發(fā)布時(shí)間:2014-02-10 09:08:49 閱讀次數(shù):3799次

  測試系統(tǒng)Window 2003 Server ,IIS 6.0 ,ASP.Net 3.5 sp1

  Dual 1.8雙核,2G內(nèi)存,14G虛擬內(nèi)存。

  為了探尋IIS的最大并發(fā)數(shù),先要做幾個(gè)假設(shè)。

  1、假設(shè)最大并發(fā)數(shù)就是當(dāng)前的連接數(shù)。意思是當(dāng)前能承受最大的連接,那么就表明最大的并發(fā)。

  2、假設(shè)IIS應(yīng)用程序池處于默認(rèn)狀態(tài),更改設(shè)置將會對最大連接數(shù)產(chǎn)生影響。

  做完假設(shè),現(xiàn)在做限制,設(shè)置站點(diǎn)保持HTTP連接,超時(shí)設(shè)置成0,就是不會超時(shí)。在站點(diǎn)請求的default.aspx頁面設(shè)置線程Thread.Sleep(int.MaxValue),接下來開發(fā)一個(gè)用來保持連接的小程序。

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("錯(cuò)誤消息:{0}", client.Messages));
} else {
rightCount++;
//Console.WriteLine(client.Messages);
}
}
}

/**
* author : yurow
* http://birdshover.cnblogs.com
* description:
*
* history : created by yurow 2009-8-16 0:29:05
*/

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();
}
}
}
 

  程序設(shè)置為只能啟動1800個(gè)線程,這是由于.Net單進(jìn)程最大線程數(shù)好像是2000個(gè)。因此,要測試最大并發(fā)數(shù),要需要同時(shí)開幾個(gè)測試進(jìn)程。把系統(tǒng)虛擬內(nèi)存調(diào)到最大值,線程過多會急劇占用內(nèi)存。現(xiàn)在開始測試。

  打開web站點(diǎn)的性能計(jì)數(shù)器,把顯示比例調(diào)成1萬。

  發(fā)現(xiàn)到5000個(gè)連接時(shí),IIS服務(wù)器崩潰(503錯(cuò)誤),去洗了個(gè)澡,發(fā)現(xiàn)IIS服務(wù)器無法自己修復(fù)錯(cuò)誤。又測試了幾次,發(fā)現(xiàn)最大并發(fā)值是8200個(gè),但是一般到5000左右就會崩潰,有時(shí)候甚至只有1000個(gè)。

  按8200個(gè)計(jì)算,一個(gè)用戶開一個(gè)瀏覽器瀏覽網(wǎng)頁,可能會占用2~3個(gè)連接(參考《IIS連接數(shù)實(shí)驗(yàn)——Web開發(fā)必讀 》),按兩個(gè)計(jì)算,那么IIS默認(rèn)情況下,最大并發(fā)數(shù)是4000個(gè)左右。

  打開應(yīng)用程序池配置,把最大工作進(jìn)程數(shù)調(diào)高(默認(rèn)為1),能有效提高最大連接數(shù)。我記得以前看過一篇文章,講的是調(diào)到5左右比較合適。

  文章來自:http://birdshover.cnblogs.com

生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關(guān)閉
程序員人生
主站蜘蛛池模板: 久久七国产精品 | 欧美亚洲第一页 | 18欧美同性视频 | 亚洲 校园 春色 另类 激情 | 日本乱妇 | 国产成人综合亚洲一区 | 欧美第一区 | 国产午夜精品久久理论片小说 | 又污又黄又无遮挡的网站国产 | 华人色 | 福利片免费一区二区三区 | 日韩国产欧美视频 | 国产成人一区二区三区免费观看 | 国产激情久久久久影 | 欧美亚洲国产精品蜜芽 | 日本69视频 | 精品国产乱码一区二区三区 | 亚洲综合欧美 | 国产成人久久 | 欧美18videosex性欧美tube1080 | 4虎1515hh永久免费 | 综合图片亚洲 | 伊人久久五月天 | 国产成人综合久久精品红 | 在线观看的网址 | 国产精品久久久久久久久久久久 | 最近中文字幕免费mv视频8 | 欧美亚洲国产精品久久第一页 | jizz免费视频 | 最近最新中文字幕高清中文字幕网 | 91porn国产在线观看 | 最近中文免费高清字幕 | 欧美另类视频一区二区三区 | 中文字幕乱码中文乱码综合 | 亚洲精品专区一区二区欧美 | 宇都宫紫苑(rion)在线播放 | 国产真实乱小说 | 国产高清精品久久久久久久 | 欧美另类视频一区二区三区 | 手机免费视频 | 欧美在线网站 |