Marcus
Marcus

Reputation: 2480

WCF request throttling

I'm using a third party .NET 4 WCF service that is added to my solution as a Service Reference. Is there a way to configure requests so that my service isn't Ddos:ing the third party service?

I'm aware of ServiceThrottling where the following parameters can be controlled:

- MaxConcurrentCalls
- MaxConcurrentSessions
- MaxConcurrentInstances

My application is single threaded so the above parameters will have no impact.

I would like to limit number requests per time period. Maybe by making a pause between each request. I could obviously write an adapter for the service and handle this myself, but the third party service contains ~200 methods so it would require lots of code.

Is it possible to throttle the requests this way by configuration?

Upvotes: 2

Views: 836

Answers (1)

Jens H
Jens H

Reputation: 4632

your question is already a couply of weeks old, so I do not know if you still need it. At least it is worth a try... Also, please correct me if I misunderstood your scenario.

As far as I understood, you want to restrict your own service to only call the third-party service one-request-after-another. I am not aware of a configurable solution for this. But, as you stated that it is possible for you to implement your own solution, I would suggest a different approach.

You might put your requests into a queue and then process one queue entry at a time. This could be implemented in a variaty of ways, depending on the environment you have to work with.

there are two solution that come to my mind.

A simple approach might be to use an in-memory queue within your own service that calls the third party once per entry and use some kind of locking. But this might need some careful thought to avoid ugly deadlocks.

The more complex, but possibly better scalable solution: You can configure your service to write into a Microsoft Message Queue (MSMQ) infrastructure and add another service that processes those messages sequentially to the third party service.

Upvotes: 2

Related Questions