Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Quota policy - Throws Error:Unexpected response code: 500

Not applicable

I want to perform quota based limitation. For each user account our add on appliation generate a unique API Key based on we need to say if this tenant has reached their limit or not say 1000 per day per tenant. We just want to use Apigee Edge for proxy and throttling.

As per my understanding we've to use the <identifier> element with the quota policy because <identifier> element does value of a variable and for every unique value of that variable it creates a seperate counter. Thats' the reason from the 'request header' i'm using ''Zapiaccesskey' value.

Here is the request header:

request.headers
Out[1]: EnvironHeaders([('Authorization', u'JWT eyJ0eXAiciOiJIUzI1NiJ9.eyJzdWIiOiJhZG1pbiIsInFzaCI6ImZjZDU1YjIzNx5WVRwaEkRBdE9ERmxNUzFoTURFeU5HUmhNR0l5TVRZZUsImlhdCI6MTQ1NjQ4Mjc5NX0.chMhYrYob99FYc8Dv6VuHC8CLnx5-aRNTHLC2znNMrI'), ('Content-Length', u'69'), ('User-Agent', u'ZFJImporter'), ('Connection', u'Keep-Alive'), ('Host', u'192.168.200.91:5000'), ('Zapiaccesskey', u'amlyYTphOWU4YzYwZS00MzExLTRjNDAtODFaW4'), ('Content-Type', u'application/json; charset=UTF-8')])


Here is what I've done so far:

1. Created an Apigee Proxy

2. Attached a Quota policy

Here is the Quota Policy I created :

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Quota async="false" continueOnError="false" enabled="true" name="Quota-1">
    <DisplayName>Quota-1</DisplayName>
    <Properties/>
    <Allow count="10"/>
    <Identifier ref="request.header.Zapiaccesskey"/>
    <Interval ref="request.header.quota_count">1</Interval>
    <Distributed>true</Distributed>
    <Synchronous>false</Synchronous>
    <TimeUnit ref="request.header.quota_timeout">month</TimeUnit>
</Quota>

The issue what I'm seeing is that even if I try to make a request using two different API keyss still I get the below error. The strange thing is that even if I try to make request with a newly generated (3rd) API key, it throw the same "Quota Limit Exceeded" error.

Error:Unexpected response code: 500 {"fault":{"faultstring":"Rate limit quota violation. Quota limit  exceeded. Identifier : ZjU3ONWUtZjY

Could someone please help me in fixing this issue.

Solved Solved
0 6 699
1 ACCEPTED SOLUTION

Hi, I'm sorry to hear you're having difficulty with the Quota policy.

I've put together a simple screencast showing it in action. I've used the exact configuration for the quota that you showed above. Maybe you can borrow from this screencast to get it working for you.

One of the things that can trip people up: Apigee Edge will remember the quota count for the duration of the quota TimeUnit. If you use a TimeUnit of 1 month, then Apigee Edge will remember if a quota has been exhausted, for up to 1 month. In which case, requests using the same identifier will receive a 500 response, indicating the quota has been exceeded. It might be easier to use a shorter TimeUnit for quotas, during testing. an hour, or a day. That way, you need to wait only 1 hour or 1 day before Apigee Edge automatically resets the quota count.

This might not be the problem you are facing though, because you said you used a newly generated identifier, and even in that case, the quota was still showing as exceeded. I cannot explain that observation.

View solution in original post

6 REPLIES 6