Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to throttle WCF service per client

Tags:

c#

wcf

I'm developing a service that will be exposed on the internet to only a few select clients. However I don't want one client to be able to call the service so often that they prevent another client calling the service, or being responded to within a reasonable time. I realise that WCF has a number of throttling configuration settings built in, but I understand that these are only for the service as a whole.

Is there any built in mechanism that will enable me to configure the service such that a single client can only carry out (eg.) 10 concurrent calls or similar?

This question is related to another question here:

Best way to secure a WCF service on the internet with few clients

where I'm still trying to determine if I need to, and how I will identify individual clients.

like image 360
hitch Avatar asked Dec 03 '25 15:12

hitch


1 Answers

The phrase you're looking for here is Rate limiting. And, no, there's no built-in way to rate-limit a WCF service. As you said, you can play with the WCF feature set around service throttling, but this is a service-level setting and not per-client.

In order to implement rate limiting the general guidance seems to be to use an in-memory collection (or something like redis for scale-out scenarios) to perform fast look-ups against the incoming user string or IP address. Then you can define some limiting algorithm around that information.

More info here and here.

like image 177
tom redfern Avatar answered Dec 07 '25 00:12

tom redfern