1

I have the following scenario:

We have an ASP.Net website, which generates a PDF report. To generate the PDF report we need to make multiple web-service calls (each call returns a part of the data). Most of the calls are to the same endpoint, but the methods and the parameters are different. To improve performance, we have thought of the following 2 approaches:

  1. Expose a web service operation that accepts parameters for all the individual calls. Internally, this method calls each of the methods one by one; when completed, it packs all the responses in a collection and sends it back. The ASP.Net web page then receives the list of responses and unpacks them and generates the report.
  2. Make parallel calls to the web service methods from the ASP.Net application. When all parallel calls are completed, collect all the responses and generate the PDF.

At first, the 2nd approach looks elegant; the problem is, how do we make the parallel web service calls. Thread.QueueUserWorkItem is not a good option as suggested here: Using ThreadPool.QueueUserWorkItem in ASP.NET in a high traffic scenario and http://williablog.net/williablog/category/Scalability.aspx

Creating new threads using new Thread() is also not great as suggested here: http://blogs.msdn.com/b/tmarq/archive/2010/04/14/performing-asynchronous-work-or-tasks-in-asp-net-applications.aspx

Further, the web apps code is layered with a UI and a Business Logic Layer that invokes the web service methods. The site is not a very heavy load site, with about 200 concurrent users.

Request to help with suggestions to improve the performance of the pdf generation process.

Thanks and Regards

Vikas

Community
  • 1
  • 1
Viking22
  • 545
  • 1
  • 7
  • 19
  • 1
    As far as I remember, generated webservice client classes generate an asynchronous version of the webservice call. Have you tried using those instead of going the multithreading way? – Menno van den Heuvel Nov 25 '11 at 14:01

2 Answers2

0

see this link , its for deference of parallel programing(kind of multithreding solution) and async programing. (use Parallel programming for CPU Intensive solutions. use Asynchronous programming for IO Bound solutions.)

if you want to use threading you can use parallel.foreach or this model :

 foreach (var item in Clients)
{
                Tasks.Add(Task.Run(() =>
                    {
                    Result.AddRange(item.GetPoint(MasterLogId, mobileNumber));                  
                }
  }

but , asyn programing it's good solution for call web services (for many requests), becuse calling web service is i/o bound! if you use threading ,you run many threads that all of them are waiting to call(pending io). and finally ,see my same problem and best answers .

Community
  • 1
  • 1
Sonador
  • 484
  • 5
  • 13
0

Take a look at Asynchronous Pages in ASP.NET In essence it will allow you to do what you suggest in option #2 but with mechanisms that are built into ASP.NET rather than having to tap into lower level threading techniques.

e36M3
  • 5,952
  • 6
  • 36
  • 47