WCF服务行为

时间:2013-01-20 02:12:47

标签: wcf wcf-binding http.sys

我有一个自托管的WCF服务,我在Windows服务中托管。我的绑定设置为basicHttpBinding。

当我运行该服务时,我运行netsh http show servicestate,我看到我的服务正在监听;但是,我似乎无法正确配置参数。

在IIS下托管时,它的执行速度大约低20%,因此我想自我托管。如何配置自托管WCF服务的参数以匹配IIS?我特别关注的参数是超时,最大连接数,超时数和最大请求​​数。我试图提出服务行为;但是,它没有做任何事情。我在HTTP /参数下添加了MaxConnections,但没有运气。任何帮助表示赞赏。

以下是在IIS下托管的输出:

Server session ID: F9000000200015DA

    Version: 2.0
    State: Active
    Properties:
        Max bandwidth: 4294967295
        Timeouts:
            Entity body timeout (secs): 120
            Drain entity body timeout (secs): 120
            Request queue timeout (secs): 65535
            Idle connection timeout (secs): 120
            Header wait timeout (secs): 120
            Minimum send rate (bytes/sec): 240
    URL groups:
    URL group ID: F600000040001737
        State: Active
        Request queue name: MyService
        Properties:
            Max bandwidth: inherited
            Max connections: 4294967295
            Timeouts:
                Entity body timeout (secs): 120
                Drain entity body timeout (secs): 120
                Request queue timeout (secs): 65535
                Idle connection timeout (secs): 120
                Header wait timeout (secs): 0
                Minimum send rate (bytes/sec): 0
            Logging information:
                Log directory: C:\inetpub\logs\LogFiles\W3SVC2
                Log format: 0
            Authentication Configuration:
                Authentication schemes enabled:
            Number of registered URLs: 1
            Registered URLs:
                HTTP://*:80/

Request queues:
    Request queue name: MyService
        Version: 2.0
        State: Active
        Request queue 503 verbosity level: Basic
        Max requests: 3000
        Number of active processes attached: 1
        Controller process ID: 1400
        Process IDs:

以下是我自托管时的输出:

Server session ID: FC00000120000229

    Version: 2.0
    State: Active
    Properties:
        Max bandwidth: 4294967295
        Timeouts:
            Entity body timeout (secs): 120
            Drain entity body timeout (secs): 120
            Request queue timeout (secs): 120
            Idle connection timeout (secs): 120
            Header wait timeout (secs): 120
            Minimum send rate (bytes/sec): 150
    URL groups:
    URL group ID: FB000001400005DE
        State: Active
        Request queue name: Request queue is unnamed.
        Properties:
            Max bandwidth: inherited
            Max connections: inherited
            Timeouts:
                Timeout values inherited
            Number of registered URLs: 1
            Registered URLs:
                HTTP://+:80/MyService/

Request queues:
    Request queue name: Request queue is unnamed.
        Version: 2.0
        State: Active
        Request queue 503 verbosity level: Basic
        Max requests: 1000

这是我的服务配置文件:

<?xml version="1.0"?> <configuration>   <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MyThrottle">
          <serviceThrottling maxConcurrentCalls="3000" maxConcurrentSessions="3000"
            maxConcurrentInstances="12500" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <basicHttpBinding>
        <binding name="MyConfig" closeTimeout="00:10:00"
          openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
          maxReceivedMessageSize="10485760" useDefaultWebProxy="false">
          <readerQuotas maxDepth="999999999" maxStringContentLength="999999999"
            maxArrayLength="999999999" maxBytesPerRead="999999999" maxNameTableCharCount="999999999" />
          <security mode="None">
            <transport clientCredentialType="None" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="MyThrottle" name="This.MyService">
        <endpoint address="http://localhost:80/MyService" binding="basicHttpBinding"
          bindingConfiguration="MyConfig" name="MyService"
          contract="This.IMyService" />
      </service>
    </services>   </system.serviceModel> </configuration>

1 个答案:

答案 0 :(得分:0)

以下是Microsoft HTTP.SYS团队的官方回复:

“Max Connections”= HttpServerConnectionsProperty输出与“Max Requests”= HttpServerQueueLengthProperty的含义不同。

HttpListener不允许您为URL组设置Max Connections属性(HttpServerConnectionsProperty)或为请求队列设置Max requests属性(HttpServerQueueLengthProperty),因此WCF无法在通过代码进行自托管时设置http.sys设置。