How to compose SpikeArrest and Quota policy in the same proxy

Not applicable

Hi,

I have a proxy. I'd like to set the overall spike arrest limit for the API proxy level at 20 TPS.

There are 2 consumers of the API. For consumer1, I have to restrict for 1 TPS and the other consumer2 can utilize the whole spike volume 20 TSP or 19TPS(when consumer utilize 1 TPS) .

How this can be achieved?

I have tried as below

1. Set the Spike arrest policy as 20 TPS

2. Set the Quota policy afor consumer1 as 60 per minute.

here i lose the scope of 1 TPS for that consumer where as am able to control him over a minute but not on second.

Kindly advise.

1 1 356
1 REPLY 1

Hi @Pavankumar Goru

You must understand the different purposes of Spike Arrest and Quota.

Spike Arrest is to protect your system from high spikes in load. It is not intended to replace a Quota. Quota is not useful for limiting load to the second.

It sounds to me that you wish to enforce a 2-level Quota. Because Edge is so flexible, it's easily possible. Here's how you'd do it.

Use 2 Quota policies, configured differently.

  • The first Quota policy should use the metadata provided in the API product. Use client_id as the Identifier for the Quota. (The identifier is the counting bucket. )
  • Configure the consumer1 "app" to be authorized on an API Product that has a quota limit set to 60 per minute.
  • Configure the consumer2 "app" to be authorized on a different API Product, that has a quota limit set to 1200 per minute.
  • Configure a second Quota policy, occurring after the first. Use api.proxy as the Identifier for the Quota. Use a fixed value of 1200 per minute in this policy.

The way this works : the first quota check runs, and it counts based on client_id. Therefore Consumer1 gets 20 requests per minute, while consumer2 gets allowed 1200.

The second Quota then runs, if and only if the first check has passed. The second quota enforces that the api proxy itself can be called a maximum of 1200 times per minute.

The call goes through only if both Quota checks pass.

If you also want a spike arrest, you can insert that as well, probably in front of the Quota policies. Usually the spike arrest is some multiple ABOVE the quota rate. Eg, if your quota enforcement level is 1200/minute, then your per-second spike arrest will be 50 or 80, not 20 TPS.

Does this make sense?

Good luck!