Skip to main content

Protecting with Apigee Spike Arrest

Hands-On Lab

 

Photo of Joseph Lowery

Joseph Lowery

Google Cloud Training Architect II in Content

Length

00:30:00

Difficulty

Beginner

Sudden surges in network traffic—regardless of the reason—can severely impact the performance of an API, even to the point of overwhelming it. Apigee has a built-in policy capable of handling such surges: the Spike Arrest policy. In this hands-on lab, we'll implement the Spike Arrest policy and configure it so that traffic is throttled on a per-developer basis.

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.

Protecting with Apigee Spike Arrest

Introduction

Sudden surges in network traffic—regardless of the reason—can severely impact the performance of an API, even to the point of overwhelming it. Apigee has a built-in policy capable of handling such surges: the Spike Arrest policy. In this hands-on lab, we'll implement the Spike Arrest policy and configure it so that traffic is throttled on a per-developer basis.

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.

Add the Spike Arrest Policy

  1. On the Apigee dashboard page, click API Proxies.
  2. Choose LA-Weather from the list of proxies.
  3. Switch to the DEVELOP tab.
  4. In the Proxy Endpoints section of the Navigator, select PreFlow.
  5. In the Request area, click + Step.
  6. Under Traffic Management, select Spike Arrest.
  7. Leave the default names and click Add.
  8. If necessary, drag the Spike Arrest policy so that it is among the first executed.

Set the Desired Parameters

  1. Select the Spike Arrest policy.
  2. Modify the code to the following: <Identifier ref="request.queryparam.dev"/> <MessageWeight ref="request.header.weight"/> <Rate>2pm</Rate>
  3. Click Save.

Test for Spiking Traffic

  1. Select the TRACE tab.
  2. In the URL field, add the following query parameters to the API proxy URI: ?appid=[YOUR_OPENWEATHERMAP_API_KEY]&q=phoenix&dev=1 If you do not have a OpenWeatherMap API key, use fd4698c940c6d1da602a70ac34f0b147.
  3. Click Start Trace Session.
  4. Click Send 3-4 times within a minute.
  5. Review the results.
  6. Change the dev parameter value to 2.
  7. Click Send again.

Conclusion

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