Skip to content

Commit 9537a37

Browse files
committed
document route_null and route_ratelim
1 parent 1fcd14e commit 9537a37

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

content/features/proxy/reference.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ route_direct{
2121

2222
Replace <var>POOL_NAME</var> with the name of a pool defined in the `pools{}` block of your configuration file.
2323

24+
### `route_null`
25+
26+
Immediately returns an empty response, matching the type of request sent to
27+
it. Get requests result in a `MISS` result. Set requests result in a `NOT_STORED`
28+
result. Numerical, touch, and delete commands result in `NOT_FOUND`.
29+
30+
```lua
31+
route_null{}
32+
```
33+
2434
### `route_allsync`
2535

2636
Routes the request to a list of pools, in parallel.
@@ -127,6 +137,54 @@ Replace the following:
127137
* <var>MISS_BOOLEAN</var>: if true, then the proxy treats both misses and errors as failures. Otherwise, the proxy counts only errors as failures.
128138
* <var>WAIT_FLOAT</var>: wait at most this amount of time in seconds before failing over to the next pool (fractional time allowed)
129139

140+
### `route_ratelim`
141+
142+
NOTE: This route handler is EXPERIMENTAL, and the arguments or behavior may
143+
change.
144+
145+
This route handler uses a Token Bucket Filter algorithm to rate limit requests
146+
sent to the child pool. On failure a "null" response is returned (see
147+
`route_null`)
148+
149+
```lua
150+
route_ratelim{
151+
child = "{{<var>}}POOL_NAME{{</var>}}",
152+
limit = {{<var>}}LIMIT{{</var>}},
153+
fillrate = {{<var>}}FILLRATE{{</var>}},
154+
tickrate = {{<var>}}MILLISECONDS{{</var>}},
155+
global = {{<var>}}GLOBAL_BOOLEAN{{</var>}},
156+
fail_until_limit = {{<var>}}FAIL_UNTIL_BOOLEAN{{</var>}},
157+
}
158+
```
159+
160+
Replace <var>POOL_NAME</var> with the name of a pool defined in the `pools{}` block of your configuration file.
161+
* <var>LIMIT</var>: The maximum size of the buckets, in requests.
162+
* <var>FILLRATE</var>: The amount to refill the bucket, after every `fillrate` amount of time has passed.
163+
* <var>TICKRATE</var>: The amount of time, in milliseconds, between each refill of the bucket.
164+
* <var>GLOBAL_BOOLEAN</var>: By default one bucket is created for every worker
165+
thread the proxy is configured for. With this option set to true, this limit
166+
is global to the whole process, at the expense of being slower. In this case
167+
the bucket data structure is covered by a single mutex.
168+
* <var>FAIL_UNTIL_BOOLEAN</var>: With this set to true, the limiter will
169+
instead fail until the rate limit has been exceeded. This can be used to
170+
automatically enable a proxy-local data cache when the server is busy.
171+
172+
### `route_random`
173+
174+
Routes to a random pool from the list of children.
175+
176+
```lua
177+
route_random{
178+
children = {{<var>}}POOL_LIST_OR_SET_NAME{{</var>}},
179+
}
180+
```
181+
182+
Replace <var>POOL_LIST_OR_SET_NAME</var> with either one of the following:
183+
184+
* A bracketed, comma-separated list of of pool names defined in the `pools{}` block of your configuration file—for example, `{ "cust_pool_1", "cust_pool_2" }`.
185+
186+
* The name of a set defined in the `pools{}` block of your configuration file—for example, `"set_cust_pools"`.
187+
130188
### `route_zfailover`
131189

132190
NOTE: This function has been deprecated. Its functionality is available in

0 commit comments

Comments
 (0)