简体   繁体   English

Web场和负载平衡环境中的WCF服务配置

[英]WCF Service configuration in Web Farm and Load Balancing envrionment

I want to configure ASP.NET Website Project using WCF Service[NetTcp] (both in c#) for web-farm (for website) and NLB Load balancing (for service). 我想使用WCF Service [NetTcp](均为c#)针对Web场(针对网站)和NLB负载平衡(针对服务)配置ASP.NET网站项目。 I would like to configure following options for same. 我想为以下配置以下选项。

NetTcpBinding.maxConcurrentCalls, NetTcpBinding.ListenBacklog and NetTcpBinding.MaxConnections NetTcpBinding.maxConcurrentCalls,NetTcpBinding.ListenBacklog和NetTcpBinding.MaxConnections

Note: During single machine configuration when I changed value of NetTcpBinding.ListenBacklog and NetTcpBinding.MaxConnections in WCF Service project to more that 10, which is default value. 注意:在单机配置期间,我将WCF Service项目中的NetTcpBinding.ListenBacklog和NetTcpBinding.MaxConnections的值更改为大于10的默认值。 I got exception. 我有例外。 When I changed this value in Website it was working fine. 当我在“网站”中更改此值时,它工作正常。 Due to this I had to keep in default configuration. 因此,我必须保持默认配置。 Not sure why this is the case. 不知道为什么会这样。 If anyone could explain this it would be helpful. 如果有人可以解释这一点,将很有帮助。

Following reference gives idea how to configure in given environment but does not tell how to go about it. 以下参考资料给出了如何在给定环境中进行配置的想法,但并未说明如何进行配置。

Ref: http://msdn.microsoft.com/en-us/library/ee377061%28BTS.10%29.aspx 参考: http : //msdn.microsoft.com/en-us/library/ee377061%28BTS.10%29.aspx

Update: 更新:

Let me simplify a bit. 让我简化一下。 Lets say I have following configuration. 可以说我有以下配置。

  • 2 IIS servers in Web Farm. Web场中的2台IIS服务器。
  • 3 WCF Service Servers (NetTcp) in NLB NLB中的3个WCF服务服务器(NetTcp)
  • Default config. 默认配置。 for single instance. 对于单个实例。
    • NetTcpBinding.ListenBacklog: 10 NetTcpBinding.ListenBacklog:10
    • NetTcpBinding.MaxConnections: 10 NetTcpBinding.MaxConnections:10
    • NetTcpBinding.maxConcurrentCalls: 16 NetTcpBinding.maxConcurrentCalls:16

Now what will be my configuration setting in this environment. 现在在此环境中我的配置设置是什么。 Will it be same as above or will be as follows. 与上面相同还是如下。

  • Suggested config. 建议的配置。 for single WebFarm/NLB 对于单个WebFarm / NLB
    • NetTcpBinding.ListenBacklog: 30 (10*3) NetTcpBinding.ListenBacklog:30(10 * 3)
    • NetTcpBinding.MaxConnections: 30 (10*3) NetTcpBinding.MaxConnections:30(10 * 3)
    • NetTcpBinding.maxConcurrentCalls: 48 (16*3) NetTcpBinding.maxConcurrentCalls:48(16 * 3)

For load balancing net.tcp using Windows NLB you should have a shorter leaseTimeout with a value of 30 sec being suggested in MSDN . 对于使用Windows NLB的net.tcp负载平衡,您应该使用更短的leaseTimeout,在MSDN中建议使用30秒的值。 Make sure you use per call services. 确保使用每次通话服务。 Configure NLB to balance individual port for each endpoint (if you have multiple endpoints) rather than port range as this increases performance. 配置NLB以平衡每个端点(如果您有多个端点)的单个端口而不是端口范围,因为这可以提高性能。 Make sure that affinity is unchecked. 确保未选中亲和力。
I use a custom binding that has served me well as shown below 我使用了自定义绑定,对我很有用,如下所示

<customBinding>

        <binding name="netTcpBindingConfiguration_custom"
                 closeTimeout="00:01:00"
                 openTimeout="00:01:00"
                 receiveTimeout="00:10:00"
                 sendTimeout="00:01:00" >
          <transactionFlow/>
          <windowsStreamSecurity/>
          <binaryMessageEncoding/>

          <tcpTransport maxBufferPoolSize="524288"
                        maxReceivedMessageSize="5000000"
                        connectionBufferSize="8192"
                        manualAddressing="false"
                        hostNameComparisonMode="StrongWildcard"
                        channelInitializationTimeout="00:00:05"
                        maxBufferSize="5000000"
                        maxPendingConnections="20"
                        maxOutputDelay="00:00:00.2000000"
                        maxPendingAccepts="5"
                        transferMode="Buffered"
                        listenBacklog="20"
                        portSharingEnabled="false"
                        teredoEnabled="false">
            <connectionPoolSettings groupName="default"
                                    leaseTimeout="00:00:30"
                                    idleTimeout="00:02:00"
                                    maxOutboundConnectionsPerEndpoint="100"/>
          </tcpTransport>
        </binding>
</customBinding>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM