views:

401

answers:

3

I am debugging an ASMX web service that receives "bursts" of requests. i.e., it is likely that the web service will receive 100 asynchronous requests within about 1 or 2 seconds. Each request seems to take about a second to process (this is expected and I'm OK with this performance). What is important however, is that each request is dealt with sequentially and no parallel processing takes places. I do not want any concurrent request processing due to the external components called by the web service. Is there any way I can force the web service to only handle each response sequentially?

I have seen the maxconnection attribute in the machine.config but this seems to only work for outbound connections, where as I wish to throttle the incoming connections.

Please note that refactoring into WCF is not an option at this point in time.

We are usinng IIS6 on Win2003.

A: 

Perhaps you should be queuing the requests up internally and processing them one by one?

It may cause the clients to poll for results (if they even need them), but you'd get the sequential pipeline you wanted...

Kieron
The requests are all aysnchronous from the client. I have looked at creating a queuing class on the web service side but I thought that IIS must have some internal buffer for caching requests so I didnt want to (badly) reinvent the wheel.
Alex
I'd suggest looking at msmq and processing the queue via worker thread/process.
Preet Sangha
A: 

In IIS7 you can set up a limit of connections allowed to a web site. Can you use IIS7?

And what will happen to incoming connections that arrive whilst the maxmium number of connections are active? Will they be queued by IIS or will they be refused? I'll check out if we are allowed to use IIS7.
Alex
From what I found, extra requests are queued in the http.sys queue until there will be free connection. This can however make the client application timeout.
Ok this sounds like exactly the behaviour I desire. Is this behaviour just relevant to IIS 7 or does it happen in 6 too? I can control client timeouts so that is not an issue. Where did you find this info by the way?
Alex
I'm not sure about IIS6, I don't have any I can check.How? Well, I first looked in IIS because I remembered I've seen that. Than bit of google gave me answer what happens with out of limit connections.
A: 

What I've done in the past is to simply put a lock statement around any access to the external resource I was using. In my case, it was a piece of unmanaged code that claimed to be thread-safe, but which in fact would trash the C runtime library heap if accessed from more than one thread at a time.

John Saunders