增加IIS7中Web服务的最大并发连接数(负载测试)

时间:2012-03-29 11:11:02

标签: asp.net .net vb.net web-services iis-7

我正在尝试为我们的一个Web服务编写一个简单的负载测试程序,它通过IIS7提供。我正在启动一组线程(作为任务),它将Web服务称为Web引用。

尽管线程都已启动,但Web服务只能处理来自应用程序的2个并发连接。

我知道按规范simultaneous connections are limited to 2 per user。为了这个负载测试仪,我想这是一个用户,我想打开许多同时连接。

我尝试将以下内容添加到Web服务的web.config中。

  <system.net>
    <connectionManagement>
      <add address="*" maxconnection="40"/>
    </connectionManagement>
  </system.net>

我的设置如下:

Web服务位于http://devserver/MyWebServiceApp/MyWebService.asmx,MyWebServiceApp配置为应用程序。

网络方法可以被视为微不足道的东西,只需等待,比如说,在返回响应之前20秒(很容易看到任何时候只有2个连接打开)。

最简单的负载测试器代码形式如下:

Imports System.Threading.Tasks

Module SuperBasicLoadTester

    Sub Main()
        ThreadLauncher(10)
    End Sub

    Sub ThreadLauncher(ByVal numberOfThreads As Integer)
        Dim tasks(numberOfThreads - 1) As Task
        For index As Integer = 0 To numberOfThreads - 1
            tasks(index) = Task.Factory.StartNew(AddressOf SendRequest)
        Next
        Task.WaitAll(tasks)
    End Sub

    Sub SendRequest()
        Dim myWebServiceCaller As New MyWebService.ServiceMethods
        myWebServiceCaller.Url = "http://devserver/MyWebServiceApp/MyWebService.asmx"
        Dim response As String = myWebServiceCaller.MyWebServiceMethod("Some string passed to the web service method")
    End Sub

End Module

我已尝试在网络服务上指出其他负载测试软件(例如soapUI)并观察到同样的问题。

对于如何增加此连接限制(用于测试目的)的任何指示,我将不胜感激。

编辑:

  • 我应该补充说,Web服务盒正在运行Windows 2008 R2。
  • 我也同时运行SoapUI和我的loadtester,每个都是 每个只能请求2个连接(即总共4个)。

提前致谢,

阿里

2 个答案:

答案 0 :(得分:6)

我在这里找到答案:Multiple concurrent WCF calls from single client to Service

问题在于我的客户,而不是接收服务。我需要通过初始化客户端来设置System.Net.ServicePointManager.DefaultConnectionLimit

答案 1 :(得分:2)

存在系统范围的TCP连接限制,基本上这是为了在计算机上使用太多资源来停止TCP。

点击此处查看是否有帮助,但要小心,因为这需要一些注册表调整: http://smallvoid.com/article/winnt-tcpip-max-limit.html