3

我尝试使用 WCF 服务运行压力测试。压力测试模拟场景“许多并发用户执行一个服务请求”。我使用自托管的 WCF 服务、basicHttpBinding 和 ssl 支持。

在这个测试中,我发现性能存在问题。这些问题的原因是服务没有关闭连接,因此打开的连接数不断增加(我使用 netstat -n 来计算打开的连接数)。我试图禁用 keep-alive 属性,但没有帮助。任何想法,可能是什么问题?

这是服务器配置:

    <system.serviceModel>
    <services>
        <service 
            name="WorkerService"
            behaviorConfiguration="SecureBehavior"> 
            <endpoint 
                address="" 
                binding="customBinding"
                bindingConfiguration="BasicHttpSSLWithoutKeepAliveBinding"
                contract="IWorkerService"
            />
            <host>
                <baseAddresses>
                    <add baseAddress="https://localhost/service" />
                </baseAddresses>
            </host>
        </service>
    </services>

    <behaviors>
        <serviceBehaviors>
            <behavior name="SecureBehavior">
              <serviceMetadata httpsGetEnabled="true" httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
        </serviceBehaviors>
    </behaviors>

    <bindings>
      <customBinding>
        <binding name="BasicHttpSSLWithoutKeepAliveBinding">
          <textMessageEncoding />
          <httpsTransport allowCookies="false" 
                          keepAliveEnabled="false"/>
        </binding>
      </customBinding>  
    </bindings>
</system.serviceModel>

这是计算打开连接的小脚本:

@echo off
setlocal enabledelayedexpansion

:loop
set lc=0

for /f "usebackq delims=_" %%i in (`netstat -n`) do (
  set /a lc=!lc! + 1
)

echo %lc%
ping -n 2 -w 1000 127.0.0.1 > nul
goto loop
endlocal
4

0 回答 0