Note that there are some explanatory texts on larger screens.

plurals
  1. POWCF Performance Question
    primarykey
    data
    text
    <p>I'm pretty much new at WCF and have a performance question. I have the following code that is executing at the client:</p> <pre><code> try { for (int i = 0; i &lt; 20; i++) { stopwatch.Reset(); stopwatch.Start(); var psn = client.GetPsnByPsnId(21); var psnList = client.GetPsnBySmartBizClientId(2); var container = client.GetContainerByContainerId(3); var containerList = client.GetContainerBySmartBizClientId(2); stopwatch.Stop(); Console.WriteLine(string.Format("Pass # {0} completed in {1} milliseconds", i + 1,stopwatch.ElapsedMilliseconds)); } } catch (FaultException exception) { MessageBox.Show(string.Format("Error occurred. The error message is {0}", exception.Message)); } finally { client.Close(); client = null; } </code></pre> <p>This code hits a WCF service that is hosted as a Windows service using HTTP binding under .NET 4.0. The problem I have is this. The very first time through the loop, on the very first WCF call (client.GetPsnByPsnID()), there is a very significant delay, 10+ seconds in fact. But, after this first call, each subsequent call, each time through the loop, takes &lt; 1 second, as I would expect. I'm sure this is a WCF issue because if I call the first method outside of WCF, I get &lt; 1 second performance.</p> <p>Anyone have any idea what might be causing the initial delay?</p> <p>EDIT: Here is the OnStart code for the Windows Service:</p> <pre><code>protected override void OnStart(string[] args) { serviceHost = new ServiceHost(typeof(ServiceMethods),new Uri("http://111.111.111.111:1111/Psn")); // Add an endpoint and the methods the endpoint will support. serviceHost.AddServiceEndpoint(typeof(IServiceMethods), WcfConfiguration.GenerateBinding(Enumerations.WcfBindingType.HTTP), ""); WcfConfiguration.CreateMexData(serviceHost); serviceHost.Open(); } </code></pre> <p>And here is the GenerateBinding method:</p> <pre><code>public static System.ServiceModel.Channels.Binding GenerateBinding(Enumerations.WcfBindingType bindingType) { System.ServiceModel.Channels.Binding binding = null; BasicHttpBinding httpBinding = new BasicHttpBinding(); httpBinding.Security.Mode = ((bindingType == Enumerations.WcfBindingType.HTTP) ? BasicHttpSecurityMode.None : BasicHttpSecurityMode.Transport); httpBinding.OpenTimeout = new TimeSpan(0, 0, 30); httpBinding.SendTimeout = new TimeSpan(0, 0, 30); httpBinding.ReceiveTimeout = new TimeSpan(0, 0, 30); httpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None; httpBinding.ReaderQuotas.MaxStringContentLength = httpBinding.ReaderQuotas.MaxStringContentLength; httpBinding.MaxReceivedMessageSize = httpBinding.MaxReceivedMessageSize; httpBinding.ReaderQuotas.MaxArrayLength = 1048576; httpBinding.MaxBufferSize = httpBinding.MaxBufferSize; binding = httpBinding; break; } return binding; } public static void CreateMexData(ServiceHost host) { ServiceMetadataBehavior behavior = new ServiceMetadataBehavior(); behavior.HttpGetEnabled = true; host.Description.Behaviors.Add(behavior); host.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexHttpBinding(), "mex"); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload