Quota shared between API proxies within Product

Not applicable

Hello, I have created Product with 4 API proxies. In the documentation (http://docs.apigee.com/api-services/reference/quota-policy), I have found that: "Quota counters are scoped to the API proxy that contains the Quota policy. If multiple API proxies contain Quota policies with the same name, the counters are maintained separately." Does it mean that I cannot use 1 quota for the whole Product? Could you suggest how should I achieve it, please?

Regards,

Andrzej

Solved Solved
5 15 2,116
2 ACCEPTED SOLUTIONS

adas
Participant V

@Andrzej Currently the concept of a global quota counter doesn't exist, which means you would have quota counters being maintained at each api proxy level. So even if you have 1 api product and that enforcing quota across multiple api proxies, each would have their own counters rather than a shared counter. However there are ways to work around this problem.

We have a concept of proxy chaining which can help in these cases. You can have an apiproxy which enforces the quota policy and other proxies which make a callout (service callout) to this policy in the request preflow. This way you are not duplicating the policy definitions across multiple api proxies and at the same time being able to leverage the shared quota. I am attaching an example for you:

Here's my apiproduct configuration:

2444-quota.png

I have created a developer app using this apiproduct - "quota". And then I have created 2 api proxies, api_v1 and api_v2 which use proxy chaining underneath to call the Quota_v1 apiproxy using a service callout which enforces the quota. You would see the quota getting enforced for api_v1 and api_v2 both because the quota counters are now being maintained at "Quota_v1" api proxy level. Just to show the benefit of proxy chaining, I have also added a verifyApiKey policy in the Quota_v1 proxy which gets enforced for both the api_v1 and api_v2.

Let me know if this works for you. If this resolves your query, kindly accept the answer by clicking on the "Accept" option below:

You can also find out more about proxy chaining here or in my community post about proxy chaining here

api-v1-rev1-2016-04-18.zip

api-v2-rev1-2016-04-18.zip

quota-v1-rev1-2016-04-18.zip

View solution in original post

Hi @Andrzej, you are right, Quota do not span across proxies.

Hence to achieve your usecase - you need a mechanism thro which API calls across proxies can be counted - I could think of ways to do that with the help of Proxy Chaining

one could be

> create a proxy with No Target, with just the Quota policy - enforcing the quota values configured at the API Product

> In all your other proxies, create a ServiceCallout with LocalTargetConnection to this Quota-proxy

This will enable the runtime to count all API calls across the proxies and hence apply quota for all proxies in a product

I understand, this is not very elegant - but just a workaround. But we have on our roadmap to address this issue

Thanks,

Mukundha

View solution in original post

15 REPLIES 15

Great Question @Andrzej , I believe above feature is available part of Apigee Edge AddOn Monetization but not in core. I might be wrong also. Let me ask Apigeeks here using "Ask An Expert" section on right sidebar. Stay tuned.

adas
Participant V

@Andrzej Currently the concept of a global quota counter doesn't exist, which means you would have quota counters being maintained at each api proxy level. So even if you have 1 api product and that enforcing quota across multiple api proxies, each would have their own counters rather than a shared counter. However there are ways to work around this problem.

We have a concept of proxy chaining which can help in these cases. You can have an apiproxy which enforces the quota policy and other proxies which make a callout (service callout) to this policy in the request preflow. This way you are not duplicating the policy definitions across multiple api proxies and at the same time being able to leverage the shared quota. I am attaching an example for you:

Here's my apiproduct configuration:

2444-quota.png

I have created a developer app using this apiproduct - "quota". And then I have created 2 api proxies, api_v1 and api_v2 which use proxy chaining underneath to call the Quota_v1 apiproxy using a service callout which enforces the quota. You would see the quota getting enforced for api_v1 and api_v2 both because the quota counters are now being maintained at "Quota_v1" api proxy level. Just to show the benefit of proxy chaining, I have also added a verifyApiKey policy in the Quota_v1 proxy which gets enforced for both the api_v1 and api_v2.

Let me know if this works for you. If this resolves your query, kindly accept the answer by clicking on the "Accept" option below:

You can also find out more about proxy chaining here or in my community post about proxy chaining here

api-v1-rev1-2016-04-18.zip

api-v2-rev1-2016-04-18.zip

quota-v1-rev1-2016-04-18.zip

@Andrzej

We are coming up with a concept of "global proxies/policies" called proxy interceptors which would work very similar to the above approach but the interceptor would get invoked implicitly for all your api calls once enabled. This feature is still in development, and while this gets ready and rolled out, proxy chaining is your best bet for such use cases.

Hi @arghya das,

thank you for your answer and sample configuration! I am looking forward to using proxy interceptors but for now, following your suggestion, I'll go with proxy chaining.

Regards,

Andrzej

Hi @arghya das,

Could you let me know what is the estimated date of introducing mentioned by you "proxy interceptor"?

Kind regards,

Tomasz

Nice solution @Dino-at-Google, would have been nice if a Shared Flow worked instead of proxy chaining.

Ack. I understand what you're saying. We can look into that.

Hi @Andrzej, you are right, Quota do not span across proxies.

Hence to achieve your usecase - you need a mechanism thro which API calls across proxies can be counted - I could think of ways to do that with the help of Proxy Chaining

one could be

> create a proxy with No Target, with just the Quota policy - enforcing the quota values configured at the API Product

> In all your other proxies, create a ServiceCallout with LocalTargetConnection to this Quota-proxy

This will enable the runtime to count all API calls across the proxies and hence apply quota for all proxies in a product

I understand, this is not very elegant - but just a workaround. But we have on our roadmap to address this issue

Thanks,

Mukundha

Has this issue been addressed now?

A fix is in the works. ref: b/149229963

Hi Dino, what is the fix you are referring to? Will the global quota be introduced?

@gnanasekaran You mention an update was on the roadmap, has anything new been introduced?

It has not been delivered.  Still on the backlog. I suggest you connect with your customer account team to raise the priority of this if you think it is important.

I'm guessing this is still on the backlog? I haven't seen any notice or docs about it.

yes, as far as I am aware, the change has not yet been approved and merged. @VenkatSadars FYI  ref: b/149229963