Jason Bourne
Jason Bourne

Reputation: 13

Best design for long process in Web Service

I have a design question on how to best approach a process within an existing DotNet2 web service I have inherited.

At a high level the process at the moment is as follows

Client

  1. User starts new request via web service call from client/server app
  2. Request and tasks created and saved to database.
  3. New thread created that begins processing the request
  4. Request ID returned to client (client polls using ID).

Thread

  1. Loads up request detail and the multiple tasks
  2. For each task it requests XML via another service (approx 2 sec wait)
  3. Passes XML to another service for processing (approx 3 sec wait)
  4. Repeat until all tasks complete
  5. Marks request completed (client will know its finished)

Overall this takes approximately 30 seconds for a request of 6 tasks. With each task being performed sequentially it is clearly inefficient.

Would it be better to break out each task again on a separate thread and then when they are all complete mark the request as completed?

My reservation is that I am immediately duplicating the number of threads by up to a factor of 6-10 (number of tasks) and concerned on how this would impact on IIS. I estimate that I could cut a normal 30 second call down to around 5 seconds if I had each task processing concurrently but under load would this design suffer?

The current design is operating well and users have no problem with the time taken to process but I would prefer it work faster if possible.

Is this just a completely bad design and if so is there a better approach? I am limited by the current DotNet version at present.

Thanks

Upvotes: 0

Views: 688

Answers (1)

leetibbett
leetibbett

Reputation: 843

If you are worried about IIS performance you probably want to keep the jobs outside of IIS, so IMO I would consider queueing the tasks and creating a separate service to do the work. This approach would be more scaleable in that you could add or remove front end IIS servers or task processors to address a varying load. A large-scale system would most certainly perform the processing off of the front end server.

Upvotes: 1

Related Questions