Share via

Difference between rate-limit-by-key and rate-limit-by-subscription

Nagashree Balasundaram 741 Reputation points
2022-07-07T21:15:51.393+00:00

How are rate-limit-by-key and rate-limit-by-subscription handled differently in APIM. Per my understanding, every subscription is associated with a subscription id and a key. So how does it make a difference whether the counter is tracked based on the key or the subscriptionid.

Azure API Management
Azure API Management

An Azure service that provides a hybrid, multi-cloud management platform for APIs.

0 comments No comments

Answer accepted by question author

  1. DanL 81 Reputation points Microsoft Employee
    2022-07-08T23:08:29.433+00:00

    @Nagashree Balasundaram - The rate-limit-by-key policy (despite its similar-sounding name) doesn't count based on a subscription key, but rather on a counter-key you define. For example, you might limit by a user ID, or the incoming IP address as in this example:

       <rate-limit-by-key  calls="10"  
                     renewal-period="60"  
                     increment-condition="@(context.Response.StatusCode == 200)"  
                     counter-key="@(context.Request.IpAddress)"  
                     remaining-calls-variable-name="remainingCallsPerIP"/>  
    

    Please let us know if this helps.

    Reference: https://learn.microsoft.com/azure/api-management/api-management-access-restriction-policies

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.