single counter for all proxies on basis of clientId

Lets say, we have two apps ----> app 1 and app 2

Two proxies -----> proxy 1 and proxy 2

We are using common shared flow for quota and have set the quota rate has 100/m using identifier element segragating count between clientId.

Here is the requirement, the count 100/m should be across all api proxies under particular app.

Example: App 1 initiated 90 calls to proxy 1, quota should only remain 10 to proxy 2.

4 REPLIES 4

I understand the question. 
it's not possible to do what you want, today, via a sharedflow.  The problem is that the Quota policy in Apigee, currently, always implicitly adds the Proxy name into the final Quota identifier.  I mean if you specify the client_id as the Identifier in the quota policy configuration, even in that case, internally, the quota policy will add the proxy name  to the computed internal identifier. So if proxy1 and proxy2 both call into a sharedflow that holds a quota policy, the internal quota identifer is distinct, and the counts will be distinct.   There is an enhancement request in the backlog, internal reference b/149229963 , which asks to modify the implementation of the Quota policy so that the proxy name is not always implicitly added.  I don't have a confirmation that this will be implemented, or if it will, when that might happen. 

If you want this, I suggest that you contact your account team, reference b/149229963 , and state that you would like this enhancement and ask to be added to the list.

There is a workaround today - and that is to use a common PROXY to implement your quota. Rather than call to a sharedflow, use a ServiceCallout to call to a localtarget (which is a proxy), and call the Quota policy from that second proxy.  It will work, and get you the common count across proxies. 

 

There's another option to use a "common proxy" by creating a proxy with multiple basepaths (limit has recently increased from 5 to 10).

Although this adversely affects API design principles, it won't count as multiple API calls as would the Service Callout approach Dino suggested.

I agree with Dino, contact your account team to add weight to the enhancement.

Thank you for your prompt responses.

If I use a flow variables refered to api products like apiproduct.name in place of Identifier element in quota policy will divide the counter within api proxies bundled in product.

Is my understanding correct?

If I use a flow variables refered to api products like apiproduct.name in place of Identifier element in quota policy will divide the counter within api proxies bundled in product.

No.  Maybe. 

If you use apiproduct.name as Identifier, and your quota policy is in a sharedflow, then you get the same count , applied to each proxy. IF the configured count is 1000, you get 1000 for proxy1, 1000 for proxy2. 

If you use the workarounds that Kurt and I described, then yes, you get a shared counter across all proxies in the product. 

BUT!  There could be many many apps using that product.  and many instances. So. Take care using apiproduct.name as the quota identifier. You may want app.name or app identifier, etc.