我正在尝试尽可能快地优化网络服务。我在具有8个内核和8Gb RAM的Windows Server 2008机箱上的IIS7.5(.NET4)下运行的machine.config中有以下部分:
<system.web>
<httpRuntime minFreeThreads="704" minLocalRequestFreeThreads="608" />
<processModel autoConfig="true" maxWorkerThreads="100" maxIoThreads="100" minWorkerThreads="50" />
</system.web>
<system.net>
<connectionManagement>
<add address="*" maxconnection="96"/>
</connectionManagement>
</system.net>
我有一个.asmx网络服务,等待5秒然后返回。然后,我从同一台服务器上的网站运行以下C#代码:
CmsDataService service = new CmsDataService();
System.Diagnostics.Stopwatch timer = new Stopwatch();
List<Thread> threads = new List<Thread>();
for (int i = 0; i < RequestCount; i++)
{
threads.Add(new Thread(delegate()
{
service.sleepTest();
}));
}
timer.Start();
foreach (var thread in threads)
{
thread.Start();
}
while (threads.Any(t => t.IsAlive))
{
// wait
}
timer.Stop();
Response.Clear();
Response.Write(timer.ElapsedMilliseconds);
我得到以下结果:
10 requests in parallel averages = 5027ms
100 requests in parallel averages = 10016ms
1000 requests in parallel averages = 55175ms
第一个结果似乎很好,但其他结果似乎很慢。 SOAP通常这么慢还是有进一步的配置设置可以调整?