I have written a WCF application where client, server runs on the same machine. With few threads (<10) the average roundtrip time (client -> server -> client) is 400 milli sec. If I increase the threads to 200 then the average roundtrip time increases to 50 sec.
My WCF service is using basicHttp, Per-call, concurrent with 500 connections. Service is hosted in a console. Client is using the interface and communicates with service by opening a Channel using ChannelFactory. The data exchanged between server, client is at most 5 MB.
Server app.config
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="serviceBehavior1">
<serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:3999/TestWCFService/" httpsGetEnabled="false" httpsGetUrl="https://http://localhost:3999/TestWCFService/"/>
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceThrottling maxConcurrentCalls="500" maxConcurrentSessions="500" maxConcurrentInstances="500" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="basicHttp" openTimeout="02:00:00" receiveTimeout="21:00:00" sendTimeout="21:00:00" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="serviceBehavior1" name="TestWCF.TestWCFServer">
<endpoint address="http://localhost:3999/TestWCFService/" binding="basicHttpBinding" bindingConfiguration="basicHttp"
name="TestWCFServiceEndpoint" contract="TestWCF.ITestWCFInterface">
<identity> <dns value="localhost"/> </identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses> <add baseAddress="http://localhost:3999/TestWCFService/"/> </baseAddresses>
</host>
</service>
</services>
Server Code (The arguments Geometry, EntityDataFilter are defined in a separate DLL which is added as a reference in both client, server)
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Multiple)]
internal class TestWCFServer : ITestServiceInterface
{
public IList<EntityData> fetchEntityData(Geometry boundary, EntityDataFilter filter, string clientID)
{
// Fetch the EntityData from database inmemory cache with the given inputs.
// I have a timer inside the whole method. This whole method is taking ~4 milli seconds.
}
}
// Main class that starts the server
public static class TestWCFMain
{
static void Main()
{
using (ServiceHost host = new ServiceHost(typeof(VSCacheService)))
{
host.Open();
Log.Info("Server is UP !!!");
Log.Info("<Press enter to shutdown server>");
Console.ReadLine();
}
}
}
Client app config
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicHttp" openTimeout="02:00:00" receiveTimeout="21:00:00" sendTimeout="21:00:00"
maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:3999/TestWCFService/" binding="basicHttpBinding"
bindingConfiguration="basicHttp" contract="TestWCF.ITestWCFInterface" name="TestWCFServiceEndpoint" kind="" endpointConfiguration="" />
</client>
Client Code (The arguments Geometry, EntityDataFilter are defined in a separate DLL which is added as a reference in both client, server)
void fetchEntityDataFromServer(Geometry boundary, EntityDataFilter filter, string clientID)
{
var channelFactor = new ChannelFactory<ITestWCFInterface>("TestWCFServiceEndpoint");
channelFactor.Open();
var proxy = channelFactor.CreateChannel();
IList<EntityData> res = proxy.fetchEntityData(Geometry boundary, EntityDataFilter filter, string clientID);
}
I am stuck here. Any pointers to move forward will be a great help. Thanks in advance..