我正在尝试编写一个简单的负载测试程序,用于测试我们的一个通过IIS7提供的Web服务。我启动了一组线程(作为任务),这些线程使用Web引用调用Web服务。
尽管所有线程都开始了,但Web服务只能处理来自应用程序的2个并发连接。
我知道根据规范,每个用户同时连接数限制为2个。对于这个负载测试程序,我想打开许多并发连接,这也算是一个用户。
我尝试在Web服务的web.config文件中添加以下内容:
<system.net>
<connectionManagement>
<add address="*" maxconnection="40"/>
</connectionManagement>
</system.net>
我的设置如下:
网络服务位于 http://devserver/MyWebServiceApp/MyWebService.asmx,其中 MyWebServiceApp 被配置为应用程序。
Web 方法可以被视为一些微不足道的东西,只需等待 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服务进行测试并观察到了相同的问题。 请问如何增加此连接限制以进行测试,如有指教,请不吝赐教。
编辑:
- 我应该补充说明该Web服务框架正在运行Windows 2008 R2操作系统。
- 同时,我已经同时运行了SoapUI和我的负载测试器,每个程序只能请求两个连接(即总共四个连接)。
Ali
TcpNumConnections
这个设置不起作用吗?(说实话我自己从未尝试过,如果有一个UI界面就好了) - Matthew AbbottSystem.Net.ServicePointManager.DefaultConnectionLimit
。感谢您的反馈 - 非常感谢。 - alergy