Alex
Alex

Reputation: 3159

Forcing asmx web service to handle requests one at a time

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.

Upvotes: 2

Views: 1898

Answers (3)

John Saunders
John Saunders

Reputation: 161821

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.

Upvotes: 1

Jimmy S.
Jimmy S.

Reputation:

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

Upvotes: 0

Kieron
Kieron

Reputation: 27127

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...

Upvotes: 0

Related Questions