Limit each client's requests to the image routes (closes #236)
check / check (push) Successful in 54m15s
check / check (push) Successful in 54m15s
The new setting image_requests_per_minute (PIXA_IMAGE_REQUESTS_PER_MINUTE), default 600, caps the GET and HEAD requests one client sends to /v1/image/ and /v1/e/ per minute; the next is answered 429 with Retry-After and the image routes' JSON error body. It uses the login limit's RateLimit middleware, so clients are told apart the same way, behind the CORS middleware, so a preflight is not counted. 0 turns it off, as script/loadtest does; a negative or non-integer value stops startup. TestEnvironmentSetsEveryKey gains the new variable, under the standing approval in #64. To stay within the linters' limits, the sentry_dsn check moves unchanged into validateSentryDSN, and the cache_max_bytes explicit flag is set in one line. Model: opus-5-5
This commit was merged in pull request #237.
This commit is contained in:
+3
-1
@@ -94,7 +94,8 @@ main() {
|
||||
}
|
||||
|
||||
# start_containers starts a new origin and a new pixad, and waits up to 30
|
||||
# seconds for pixad's health check to pass.
|
||||
# seconds for pixad's health check to pass. pixad sees all of vegeta's
|
||||
# requests come from one address, so its image request limit is off.
|
||||
start_containers() {
|
||||
docker run -d --name "$run-origin" \
|
||||
--network "$run" --network-alias origin \
|
||||
@@ -104,6 +105,7 @@ start_containers() {
|
||||
--network "$run" -p 127.0.0.1::8080 --health-interval=1s \
|
||||
-e PIXA_SIGNING_KEY="$(head -c 32 /dev/urandom | base64)" \
|
||||
-e PIXA_ALLOWLIST_HOSTS=origin -e PIXA_ALLOW_HTTP=true \
|
||||
-e PIXA_IMAGE_REQUESTS_PER_MINUTE=0 \
|
||||
"$image" >/dev/null
|
||||
|
||||
waited=0
|
||||
|
||||
Reference in New Issue
Block a user