2

Every time my WCF service is idle for awhile (about 15mins or more) it takes sometime to initialize the new request. Usually response time is 2-3secs and first request is around 30secs. Indeed it is similar to the post explained here. Why is the first WCF client call slow?

But solution with channel factory seems on the client side and it is only for when automatically proxy is generated. I am looking for a solution on the server side because my client isn't using any proxy class or wsdl class. It simply builds a request as a string and makes an http post request. Anyway If I am providing a B2B webservice, It is not easy to say my customers to do a workaround on their client side. I am using https. Could be the problem as well?

EDIT: I have checked the IIS idle time which is already set 0 on the server.

EDIT2: when I check my travelog, I dont see any detailed information. below is how my trace code in web.config looks like and screenshot from it. Maybe I need to extend the trance information but how?

 <system.diagnostics>
  <sources>
  <source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
    <listeners>
      <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="c:\log\Traces.svclog"/>
    </listeners>
  </source>
  <source name="System.ServiceModel.MessageLogging">
    <listeners>
      <add name="xml" initializeData="c:\log\MessageLog.log"/></listeners>
  </source>  
</sources>

enter image description here

Thanks for your advises.

Community
  • 1
  • 1
Emil
  • 6,411
  • 7
  • 62
  • 112

1 Answers1

2

I suspect that it has to do with recycling and termination of process after some idle time. Every application on IIS runs under some AppPool. I have checked my settings on DefaultAppPool (win 8.1) and these are below.

Idle time out

Default recycle settings

I know that you write that you have IIS idle time set to 0 on server. But have you checked right App Pool? And is it this value that I have shown on the first screenshot?

I would also check if after some time some w3p process (responsible for your WCF app and run under your set AppPool identity) cease to exist on the server. Also, I would try to self host the WCF service to check if it is a problem with IIS or somewhere else.

pepo
  • 8,644
  • 2
  • 27
  • 42
  • thanks for your response. yes, I am checking on DefaultAppPool as well. It shouldnt be the problem. In order to test it without recycling, I have set this one 0 as well and no other traffic than my own tests. But unfortunately it is happening. I suspect 2 things. 1 of them is the channel factory mentioned in the url in my original post and the other one is https. I will try your suggestion as well. – Emil Apr 22 '14 at 14:55
  • I don't think that https could be the cause. Also, you write that you are not using proxy so it should not be channel factory at fault. But I am very curious what could it be. – pepo Apr 22 '14 at 14:59
  • when I enable my tracing on the server, It shows me that my request is processed in 6secs but on fiddler process time is 25secs. when I compare the clientconnected to server timestap is also not the same as what I have on my tracing log. If I do a second request, this time process time matches between fiddler and tracing log. clientconnected to server timestamp matches as well. It means that first request after being idle about 10mins is not executed immediately. But how to see what is happening there before it starts processing? do you have any clue? simple tracelog is not displaying details – Emil Apr 23 '14 at 11:03
  • Was a new w3p process started when you sent the first request? – pepo Apr 23 '14 at 12:06
  • I believe that you mean w3wp process. I dont observe any new process on task manager if it is the best tool to observe it. – Emil Apr 23 '14 at 12:36
  • I use also ProcessExplorer from SysInternals but id does not matter. When does the delay occur? You said that if you enable tracing you see request processed in 6 seconds. Does the delay occur before processing of the request or after the request has been processed you have to wait before the response arrives? – pepo Apr 23 '14 at 12:55
  • Can you see above my Edit2? I have added what I see in the tracelog and added my web.config code for the tracelog part. I am not getting enough information what is happening before I receive the request. It just says "process action". Maybe I am missing something for tracing. – Emil Apr 23 '14 at 13:40
  • You could set trace level from Information to Verbose. See [this link](http://msdn.microsoft.com/en-us/library/ms733025(v=vs.110).aspx) . But I don't see where the problem in trace log is. – pepo Apr 23 '14 at 20:29
  • I have finally found the possible reason but it is not sill not very clear for me. I am caching some static tables as Entity framework objects in the memory and this caching was starting with the very first request after an upload. So I added a line in the global.asax application start function that it should load before. But I dont know still why was it doing that delay even after the first request if my service waits idle more than 10 mins. – Emil May 07 '14 at 16:56
  • it looks also not happening anymore but I didnt figure out why it should reload the cache while first request already does it and it must stay until a recycling/ publishing etc. which dont happen during this idle time. – Emil May 07 '14 at 16:57