Rate Limit
Applies rate or burst limits to control API traffic.
Use the Rate Limit policy to control how many API calls a client can make within a specified time window, helping prevent misuse and enforce usage plans.
Important: Configuring rate limits with
max at or close to 2^63 - 1 (the
maximum value of a signed 64-bit integer) and very large weights such that limit counts can reach
values near 2^63 - 1 is not recommended, as results may not be accurate when applying limits that
could cause the count to exceed 2^63 - 1.For more information on the policy parameter descriptions, see DataPower Nano Gateway documentation.
Example of a Rate Limit policy in code view.
kind: RateLimit
apiVersion: api.ibm.com/v1
metadata:
name: ratelimit-sample
version: 1.0
namespace: sample
spec:
target: "Subscribed" #optional - default(all), also All, NonSubscribed, Specified
# target:
# specified:
# - "group-id-1"
# - "group-id-2"
limits: #array of any of below
- limitDef:
name: "moderate-limit" #required
definition:
$ref: sample:moderate-limit-def:1.0
operation: "update" # consume | replenish | check | update
extensions:
dp-nano-gateway:
apiVersion: api.ibm.com/v1
spec:
limits:
- globalLimit:
name: "database-rate-limit"
operation: "consume"
- aliasLimit:
name: "basic-limit"
operation: "consume"
---
kind: RateLimitDef
apiVersion: api.ibm.com/v1
metadata:
name: moderate-limit-def
namespace: sample
version: '1.0'
tags: []
spec:
consumerSpecific: true #optional, default is false
max: 50 #size of the RL bucket
intervalLen: 1
intervalUnit: "second" #minute, hour, day, week, calendarweek, calendarmonth
extensions:
dp-nano-gateway:
apiVersion: api.ibm.com/v1
spec:
exceedAction: "continue" # continue | return429 | return500
weightExpr: "$variable('workSize')" #optional - dynamic string
intervalOffset: -1
dynamicValue: "$header('request', 'organisation-name')" #optional