Skip to main content

Enforcing an Apigee Product Quota

Hands-On Lab

 

Photo of Joseph Lowery

Joseph Lowery

Google Cloud Training Architect II in Content

Length

00:30:00

Difficulty

Beginner

Apigee provides two different ways to impose a quota on an API proxy. It can be done at the proxy level by incorporating a Quota policy and setting the allowable rate. It can also be done at the API product level by defining a rate that could potentially apply to all proxies within the product. In this hands-on lab, we'll learn how to set up an API product and an API proxy so that a quota at the API product level would be enforced, superseding a quota set at the proxy level.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Enforcing an Apigee Product Quota

Introduction

Apigee provides two different ways to impose a quota on an API proxy. It can be done at the proxy level by incorporating a Quota policy and setting the allowable rate. It can also be done at the API product level by defining a rate that could potentially apply to all proxies within the product. In this hands-on lab, we'll learn how to set up an API product and an API proxy so that a quota at the API product level would be enforced, superseding a quota set at the proxy level.

Connecting to the Lab

  1. Navigate to https://cloud.google.com/apigee.
  2. Click the Try it free button.
  3. Create a free Apigee account.

Set the Quota in the API Product

  1. On the Apigee dashboard page, click API Products.
  2. Click LA Weather Product to open it.
  3. Click Edit.
  4. In the Quota section, set the following values:
    • 3 requests every 1 Minute.
  5. Click Save.

Add a Verify API Key Policy to the API Proxy

  1. In the left navigation menu, click Develop > API Proxies.
  2. Select LA-Weather from the list of proxies.
  3. In the Proxy Endpoints section of the Navigator, make sure that PreFlow is selected.
  4. In the Request area at the top of the page, click + Step.
  5. In the dialog box, scroll down to Security, and select Verify API Key.
  6. Accept the default names, and click Add.
  7. Click Save.

Add the Quota Policy

  1. In the Proxy Endpoints section of the Navigator, select PreFlow.
  2. In the Request area at the top of the page, click + Step.
  3. Under Traffic Management, select Quota.
  4. Leave the default names, and click Add.
  5. Change the values of <Distributed> and <Synchronous> to true.
  6. Delete the <StartTime> and <AsynchronousConfiguration> elements.
  7. In the "Quota-1" element, remove the type="calendar" attribute.
  8. Modify the following elements as shown: <Allow count="200" countRef="verifyapikey.Verify-API-Key.apiproduct.developer.quota.limit"/> <Interval ref="verifyapikey.Verify-API-Key.apiproduct.developer.quota.interval">1</Interval> <TimeUnit ref="verifyapikey.Verify-API-Key.apiproduct.developer.quota.timeunit">hour</TimeUnit>
  9. Under the Flow section, select the Spike Arrest policy.
  10. In the <SpikeArrest> element, change the enabled parameter from true to false.
  11. Click Save.

Test the Product-Level Quota

  1. In the side navigation menu, click Publish > Apps.
  2. Select LA Weather App from the list of apps.
  3. In the Credentials section, next to Key, click Show.
  4. Copy the revealed API key.
  5. Under Product, click LA Weather Product.
  6. On the Product page, click the LA-Weather API proxy link.
  7. Select the Trace tab.
  8. In the URL field, add the following query parameters to the API proxy URI: ?q=atlanta&apikey=[YOUR_APP_API_KEY]
  9. Click Start Trace Session.
  10. Click Send 3-4 times within one minute.
  11. Review the results.

Conclusion

Congratulations, you've successfully completed this hands-on lab!