Rate Limiting
As an API gateway, pCDN acts as the central host to all incoming and outgoing traffic from client requests. However, this traffic may also contain unwanted requests generated by web crawlers from malicious cyberware, as seen in a DDoS attack, which causes service downtime.
pCDN uses the limit-count plugin to limit the number of API requests sent to the upstream addresses within a given time.
Prerequisites
Ensure to have your login details and a route configured to proceed.
Setting a rate-limit
You can set a rate-limit in two ways:
- Route configuration: When configuring your route, you can enable the
limit-count
plugin with the set configurations. - Using the plugin section to enable for a route or upstream.
- Navigate to Plugins from your Stargate dashboard
- Click Traffic control and click Enable from the limit-count card This opens the Plugin editor.
- You can toggle to enable/disable the limit-count plugin
- Enter the required fields like the count and time_window to configure the rate limits.
- Click Submit
Test rate limiting
We set our limit-count to 4requests per 30seconds. To test this:
- Run 4 concurrent requests within this time window.
- Now run a 5th request. This returns the error message we set when configuring the rate limit.