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.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Add the Spike Arrest Policy
- On the Apigee dashboard page, click API Proxies.
- Choose LA-Weather from the list of proxies.
- Switch to the DEVELOP tab.
- In the Proxy Endpoints section of the Navigator, select PreFlow.
- In the Request area, click + Step.
- Under Traffic Management, select Spike Arrest.
- Leave the default names and click Add.
- If necessary, drag the Spike Arrest policy so that it is among the first executed.
- Set the Desired Parameters
- Select the Spike Arrest policy.
- Modify the code to the following:
<Identifier ref="request.queryparam.dev"/>
<MessageWeight ref="request.header.weight"/>
<Rate>2pm</Rate> - Click Save.
- Test for Spiking Traffic
- Select the TRACE tab.
- 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, usefd4698c940c6d1da602a70ac34f0b147
. - Click Start Trace Session.
- Click Send 3-4 times within a minute.
- Review the results.
- Change the
dev
parameter value to 2. - Click Send again.