Delay in the first call WCF service

Asked

Viewed 178 times

4

I am developing an application using WCF to distribute, everything is working smoothly, but there is a strange thing, whenever I use the service the first time it takes a lot,(almost a minute for a simple search in the database)but if I make a new call to the service it is instantaneous, if I close the application and run again then it takes time again. Someone who knows the best way to solve this?

1 answer

1

The first execution usually takes longer, because when calling for the first time the WCF Channel Factory is instantiated and prepared for communication and this operation consumes considerable resources. From the first call the Channel Factory is stored and next calls consume less time.

What can be done is to evaluate how the service is being called, if you create an instance of the service at each call or startup of the application, this will end up causing this discomfort. You can change the call form of the service by hosting it, or even creating a service (from Windows) to instantiate the WCF on the client’s computer startup. See this link: https://social.msdn.microsoft.com/Forums/vstudio/en-US/43f89088-546b-46b0-adf8-214deb1741bd/how-to-cache-channelfactory?forum=wcf

It discussed this kind of problem.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.