Skip to content

Commit 0aa69b5

Browse files
Add example for multiple rate limiters (#16895)
* Add example for multiple rate limiters * Update src/content/docs/workers/runtime-apis/bindings/rate-limit.mdx --------- Co-authored-by: ToriLindsay <[email protected]>
1 parent 1b5f1e6 commit 0aa69b5

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/content/docs/workers/runtime-apis/bindings/rate-limit.mdx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,26 @@ The `limit()` API accepts a single argument — a configuration object with the
102102

103103
You can define and configure multiple rate limiting configurations per Worker, which allows you to define different limits against incoming request and/or user parameters as needed to protect your application or upstream APIs.
104104

105+
For example, here is how you can define two rate limiting configurations for free and paid tier users:
106+
107+
```toml
108+
main = "src/index.js"
109+
110+
# Free user rate limiting
111+
[[unsafe.bindings]]
112+
name = "FREE_USER_RATE_LIMITER"
113+
type = "ratelimit"
114+
namespace_id = "1001"
115+
simple = { limit = 100, period = 60 }
116+
117+
# Paid user rate limiting
118+
[[unsafe.bindings]]
119+
name = "PAID_USER_RATE_LIMITER"
120+
type = "ratelimit"
121+
namespace_id = "1002"
122+
simple = { limit = 1000, period = 60 }
123+
```
124+
105125
## Configuration
106126

107127
A rate limiting binding has three settings:

0 commit comments

Comments
 (0)