2 API products containing 1 API proxy in common, are assigned to 2 Developer App, How will quota work?,Trying to understand Product Quotas

Not applicable

Hey All,

Reposting an old question with a slightly different twist to help me understand things better.

Imagine you have API proxy "APIPROXY" happily deployed on an org and environment. Then, you create 2 different API products:

  • API Product A
  • API Product B

Both have different rate limit settings A (1000 requests/month) and B (500 request/month).

Then you create two Developer Apps and grant access to Product A.

When will the quota kick in/prevent further requests? When each developer hits 1000 requests/month OR when the cumulative count of requests across both developer app reaches 1000 requests in the month? In other words, does the quota counter work against the developer OR against the product?

0 3 143
3 REPLIES 3

Hi

I don't know why but it looks like you have two entirely different questions in that post, including the "hi/hello" greeting part, concatenated together with a comma. How does this happen? Any ideas? I've seen this before. Are you typing the same story twice, for some reason, and wording it differently? And when you posted the question, why didn't you see that your question text was duplicated? I guess if you saw the duplication you would click the "Edit" button and fix it. I regularly see this situation, and it puzzles me.


OK, now to answer the question. The Quota policy uses an Identifier. Think of the identifier as the name on the quota counter. You can choose, by setting the identifier in the Quota policy, to have different counters. You can choose how the counters get applied. Some implications:

  • If you specify an identifier of a constant string, like "ABC",

    <Quota name="Q1" type='flexi'>
        <Interval>1</Interval>
        <TimeUnit>minute</TimeUnit>
        <Allow count='1000'/>
        <Identifier>ABC</Identifier>
    </Quota>

    ...then, that single counter will be used everywhere. API calls arriving from any device, any user, any app written by any developer, every API key in those apps, and so on.

    If you then apply different quota policies in your API proxy with Identifier "ABC" then, there is just one single counter, globally. If the limit is 1000/minute, then every API call from any app/user/developer.... gets counted within that 1000/minute.

  • If you specify an identifier with a reference to the context variable "developer.id",

    <Quota name="Q1" type='flexi'>
        <Interval>1</Interval>
        <TimeUnit>minute</TimeUnit>
        <Allow count='1000'/>
        <Identifier ref="developer.id"/>
    </Quota>

    ...then call counts of inbound API requests from any device, any user, any app written, and any API key in those apps, will be grouped by developer, and each of those groups will be counted under a distinct bucket. If you have 768 apps written by 10 different developers, and those apps are used across 1 million users, then you will have exactly 10 different quota counters, globally.

  • If you specify an identifier that refers to the client_id (aka API Key, aka Consumer ID,

    <Quota name="Q1" type='flexi'>
        <Interval>1</Interval>
        <TimeUnit>minute</TimeUnit>
        <Allow count='1000'/>
        <Identifier ref="client_id"/>
    </Quota>

    ...then, counts of inbound requests will be grouped by API KEY. If a single developer has embedded one particular API Key into the iOS version of the app, and then another API Key into the android version of the app, then you will have 2 counters, while there may be 100,000 instances of the app running, with 100,000 distinct end users.

  • Suppose you use OAuth2 (highly recommended) and specify an identifier that refers to the token

    <Quota name="Q1" type='flexi'>
        <Interval>1</Interval>
        <TimeUnit>minute</TimeUnit>
        <Allow count='1000'/>
        <Identifier ref="access_token"/>
    </Quota>

    ...then, counts of inbound requests will be grouped by token. Tokens are unique strings for each instance of each app. Therefore if you have 100,000 instances of the app running for unique end-users, you will have 100,000 quota counters. Each individual instance will get its own quota counter.

The Quota can be applied at different levels. There may be good reason for you to chain several Quota policies in series - one that uses a developer.id, and another that uses access_token.

Keep in mind the edge cases. For example, suppose the developer of the app is aware that quotas are enforced by "access_token". In that case, when the app receives a 429 (Too Many Requests) from a Quota enforcement, the app may respond by requesting a new token, and using the new token in a subsequent request. In that case, the app implicitly gets a new quota counter. So if you're not careful, a Quota enforced using access_token as the Identifier may just result in more requests for tokens, without actually enforcing any real limits in practice. The solution to THAT problem may be a quota enforcement (with a different identifier!) on the token dispensing endpoint.

Hey Dino,

Thanks so much for answering my question!

To your first comment - I could have sworn I didn't see the second half of the question in the form while submitting it. If you have seen this situation a few times before, then this is more likely a system issue than a user issue. 😄

I feel the form submission experience is a bit strange. While submitting that question (and editing it after your comments), I was displayed an error that says 'please enter more than 60 characters in the description section'. This shows up despite the fact that I have more than 60 characters in the section (as you may have noticed in the original question). I have to cut the entire content and paste it again before that message disappears.That could possibly explain why this happens.

And with regards to the answer to my question - thanks a ton! I think it cleared up quite a bit of confusion at my end. I'll do a little more reading around identifiers and that, coupled with your answer here, should certainly help.

Regards,

Thanks for the information on the duplication and the "please enter more than 60 characters" thing. I'm certain it's a system issue, and not related to you, because I have seen it in other places. That's unfortunate. I post questions here myself, but have never come across that particular behavior.

Regarding the main question, LMK if you need more information.