Rate limiting by percentage

Francis Daly francis at daoine.org
Wed Jan 25 19:09:37 UTC 2017

On Tue, Jan 24, 2017 at 04:01:18PM -0800, Thangamani J wrote:

Hi there,

> I'm in process of implementing following use case, please help me with your
> inputs.
> let's say I have endpoint /rate-limit and it should
> 75% of time, it should return "SUCCESS" as text
> 25% of time, it should return "FAILED" as text

That doesn't sound like anything to do with rate limiting to me.

It sounds more like load balancing, where you want one case to receive
three times the load of the other.

On that basis, if it must be done purely in nginx.conf, I'd probably use
"upstream" with different "server" directives with different "weight"
arguments; and have the individual servers just "return 200 SUCCESS\n"
or "return 200 FAILURE\n".

The main directives there are documented from http://nginx.org/r/upstream

(Although really, I probably wouldn't do it purely in nginx.conf.)

Francis Daly        francis at daoine.org

More information about the nginx mailing list