0

For doing long running task, is it a good approach to depending on WCF service library which hosts in Windows service?

These long running tasks are initiated from a website. Multiple users can login to the website and can initiate the task. But that much instances of long running task will be initiated. Is that an overhead to the machine? Will that cause any performance issues?

Thanks.

Dev
  • 309
  • 1
  • 8
  • 24
  • 1
    Unless you send the request on a separate thread, you'll most likely tie up the client application while it waits for a response. I suggest you revisit your design idea and look at different options - perhaps a publish subscribe model where the client would initiate the long-running task and then go about the rest of its duties, and the service could notify the client when the task was complete. Assuming the client even cares. – Tim Aug 23 '14 at 05:02
  • client would initiate the long-running task and then go about the rest of its duties, and the service could notify the client when the task was complete...Yes this is what I need. But is this possible with above approach? – Dev Aug 23 '14 at 07:56
  • 1
    Yes. Google WCF Publish Subscribe. – Tim Aug 23 '14 at 08:16
  • Whether I can use this WCF hosted in windows service approach even if the user log out from the website, but still the background work will continue? – Dev Aug 23 '14 at 08:31
  • 2
    If the client disconnects that should have no impact on the operation the WCF service started. The client won't get a notification when it's done, but it won't cause the operation to abort on the server side. – Tim Aug 23 '14 at 08:45
  • One more concern. I hope the service will by default use thread from the thread pool to handle each request (request to the service from website) if it defined as "For PerCall services". But my doubt is since it is a long running task (hours to finish), will it cause thread pool starvation when multiple user request for the service? – Dev Aug 23 '14 at 08:59
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/59850/discussion-between-dev-and-tim). – Dev Aug 23 '14 at 09:01

1 Answers1

1

Your service would need to be able to handle the number of potential users - your InstanceContextMode is the biggest question for what the WCF service will handle and Concurrency. Are you a Singleton, or PerSession, PerCall , are your Concurrency - should be Multiple. These factors will affect the performance - bear in mind the max a singleton can handle is 500 Concurrent Connections.

Sessions Instances and Concurrency : https://msdn.microsoft.com/en-us/library/ms731193(v=vs.110).aspx

You can also use a ServiceHostFactory fileless Activation on your web.

Try this link for more information - this should help you. https://sankarsan.wordpress.com/2010/06/06/fileless-activation-of-wcf-service-in-net-4-0/

Ken
  • 2,518
  • 2
  • 27
  • 35