High-concurrency WCF configuration and concurrent WCF Configuration
When using WCF as a service interface, the TCP mode is definitely more efficient than Http, and binding in Binary/MTOM format will also be highly efficient in Text format binding.
Two endpoints: one for debugging: the binding of ms-mex is used to facilitate the WCF debugging tool and remote object application, and the other is the actual working mode configuration: customBinding.
In order to increase the concurrency of the interface, the parameters of custonBinding in this experiment affect the concurrency. The following configuration shows the parameters with high tps in the experiment:
<System. serviceModel> <services> <service name = "GW. Stone. BLL. Wcf. StoneService" behaviorConfiguration = "NetTcpBehavior"> <! -- Custom contract, high-concurrency single-host about TPS, production configuration --> <endpoint address = "net. tcp: // 127.0.0.1: 50061/GWStoneService "binding =" customBinding "contract =" GW. stone. BLL. wcf. IStoneService "bindingConfiguration =" MySessionBinding "> <identity> <dns value =" localhost "/> </identity> </endpoint> <! -- Ms-mex standard contract, with a concurrency of about TPS on a single machine, remote service reference, and debugging configuration of the wcf test tool. Here, mex is a shell configuration. When the client proxy class adds a server reference, VS will automatically generate the app. config configuration file for the high concurrency configuration of the custom contract. --> <Endpoint address = "net. tcp: // 127.0.0.1: 50062/GWStoneService "binding =" mexTcpBinding "contract =" IMetadataExchange "/> </service> </services> <! -- The behavior element contains a set of service behavior settings. --> <Behaviors> <serviceBehaviors> <behavior name = "NetTcpBehavior"> <serviceMetadata httpGetEnabled = "false"/> <! -- Whether the error contains detailed information about the exception --> <serviceDebug includeExceptionDetailInFaults = "True"/> <! -- The ServiceThrottlingBehavior class can be used to control various throughput settings. These settings allow you to optimize service performance to avoid insufficient application memory. http://msdn.microsoft.com/zh-cn/library/system.servicemodel.description.servicethrottlingbehavior (V = vs.110). The aspx maxconcurrentcils attribute can limit the number of messages currently processed in the entire ServiceHost. The default value is 16 times the processor count. The MaxConcurrentInstances attribute can be used to limit the number of InstanceContext objects executed once in the entire ServiceHost. The default value is the total value of MaxConcurrentSessions and maxconcurrentcils. The MaxConcurrentSessions attribute limits the number of sessions that can be accepted by the ServiceHost object. The maximum number of sessions that a service host can accept. The default value is 100 times of the processor count. Because Load Balancing requires the experience of running applications, using ServiceThrottlingBehavior in the application configuration file is the most common method for modifying the execution process to achieve optimal service performance. Use the <serviceThrottling> element in the configuration file to set the value of this attribute. --> <Export maxconcurrentcils = "1000" maxConcurrentInstances = "1000" maxConcurrentSessions = "1000"/> </behavior> </serviceBehaviors> </behaviors> <bindings> <customBinding> <! -- WSHttpBindingBase attribute http://msdn.microsoft.com/zh-cn/library/vstudio/System.ServiceModel.WSHttpBindingBase_properties (V = vs.100). aspx --> <binding name = "MySessionBinding"> <! -- TransactionFlow gets or sets a value that indicates whether flow WS-Transactions should be supported for this binding. True if transaction flow is supported; otherwise, false. The default value is false. --> <TransactionFlow/> <! -- BinaryMessageEncoding defines a binary message encoder that encodes Windows Communication Foundation (WCF) messages in binary form on the network. http://msdn.microsoft.com/zh-cn/library/ms731780 (V = vs.110). aspx --> <binaryMessageEncoding/> <! -- ReliableSession gets an object. When you use a binding provided by the system, this object provides convenient access to available reliable session binding element attributes. http://msdn.microsoft.com/zh-cn/library/System.ServiceModel.Channels.ReliableSessionBindingElement (V = vs.110). Maximum number of channels that can be suspended during a reliable aspx maxPendingChannels session. Maximum number of pending channels. The default value is 4. The value is less than or equal to zero, or greater than 16384. The channel is suspended when it is waiting for acceptance. Once this limit is reached, no channel will be created and placed in the pending mode until this value is lowered (by accepting the suspended channel ). This is the limit for each listener. When this threshold is reached, if the remote application attempts to create a new reliable Session, the request is rejected and this error is prompted when the operation is enabled. --> <ReliableSession maxPendingChannels = "20"/> <! -- TcpTransport-defined channel is used to transmit TCP transmission of custom bound messages. http://msdn.microsoft.com/zh-cn/library/ms731366 (V = vs.110). aspx listenBacklog can be the maximum number of queued connection requests pending for Web Services. The connectionLeaseTimeout attribute limits the connection duration that the client will wait for before a connection exception occurs. This is a socket-level attribute that controls the maximum number of queued connection requests that may be suspended for Web Services. When ListenBacklog is too low, WCF stops accepting requests and deletes new connections until the server acknowledges some existing queue connections. The default value is 16 * Number of processors. MaxPendingConnections obtains or sets the maximum number of suspended connections of the shared service. The default value is 100. MaxPendingAccepts obtains or sets the maximum number of threads that cannot be completed at the end of the shared service listener. The default value is 2. --> <TcpTransport listenBacklog = "400" maxPendingConnections = "1000" maxPendingAccepts = "10"/> </binding> </customBinding> </bindings> </system. serviceModel>