logo       

Re: Alternatives to slow requests that are saturating the thread pool: msg#00100

windows.devel.dotnet.web

Subject: Re: Alternatives to slow requests that are saturating the thread pool

You shouldn't need to create your own thread pool here.

You can write an async handler and then invoke the web service asynchronously.
If you're using the web service wrappers generated by VS.NET (or by WSDL.EXE)
these all have BeginXxx and EndXxx versions. Despite what the documentation
implies, these don't consume any threads while they are running. This allows
you to handle far more concurrent requests than you have threads.

So your async handlers' BeginSomething method would call the web service
wrapper's BeginXxx method, and could then return, freeing up the thread. (You
can either implement your own IAsyncResult, or just return the one the web
service proxy returns.) Something a bit like this:

public class WebServiceAsync : System.Web.Services.WebService
{
private SlowWebService slowService = new SlowWebService();

[WebMethod]
public IAsyncResult BeginHelloWorld(
AsyncCallback cb,
object s)
{
return slowService.BeginFoo();
}

[WebMethod]
public string EndHelloWorld(IAsyncResult call)
{
return slowService.EndFoo(call);
}
}

Yes it's slightly more code than 1. But only a bit, and it is likely to scale
much further than either of the approaches you described.


--
Ian Griffiths
DevelopMentor


> -----Original Message-----
> From: Javier Martinez Álvarez
>
> I have slow request that are saturating the thread pool because these
> request are invoking a slow web service too.
>
> To try resolve it I have read that there are two solutions:
>
> 1) I could change the upper limit of the thread pool. I'm understand it.
>
> 2) Using asynchronous handlers. Create my own thread pool, allocate
> distinct
> threads to service them, freeing up the original thread pool thread to
> service additional requests. I don't understand well this second solution.
> Where is the advantage with the first one? It seems poor because there is
> a
> more code to execute.

===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise