From 0302b2e22ac98eb751d7807994e5ed9a018c40f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Murat=20=C3=96ZDEM=C4=B0R?= Date: Mon, 18 May 2026 10:23:57 +0300 Subject: [PATCH] docs(roadmap): standardize rate limit configuration with constants - Recommended defining rate limit thresholds as header constants in init.sh. - Updated documentation snippet to use GLOBAL_LIMIT_COUNT and GLOBAL_LIMIT_WINDOW variables. - Improved maintainability for future rate limit adjustments. --- roadmap/prod-env/03-infra-stack-changes.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/roadmap/prod-env/03-infra-stack-changes.md b/roadmap/prod-env/03-infra-stack-changes.md index d288ee2..d3b442a 100644 --- a/roadmap/prod-env/03-infra-stack-changes.md +++ b/roadmap/prod-env/03-infra-stack-changes.md @@ -111,9 +111,14 @@ Keep the following APISIX plugin limits in `init/apisix-core/init.sh` for `test/ | Auth routes `/v1/auth/*`, `/v1/users/*` | `limit-count` | `count: 12`, `time_window: 60` per `remote_addr` | | Global rule | `limit-count` | `count: 60`, `time_window: 60` per `remote_addr` | -Update the global rate limit block in `init/apisix-core/init.sh`: +Update the global rate limit block in `init/apisix-core/init.sh`. Define threshold constants at the script header to ensure consistency and ease of updates: ```bash +# Define at the top of init.sh +GLOBAL_LIMIT_COUNT=60 +GLOBAL_LIMIT_WINDOW=60 + +# ... later in the script ... if [[ "$PROFILE" != "dev" ]]; then if [[ "$PROFILE" == "prod" ]]; then RATE_POLICY="redis" @@ -125,7 +130,7 @@ if [[ "$PROFILE" != "dev" ]]; then call_api "global rate limit" -X PUT "$APISIX_ADMIN_URL/global_rules/1" \ -H "X-API-KEY: $API_KEY" -H "Content-Type: application/json" \ - -d '{"plugins":{"limit-count":{"count":60,"time_window":60,"key_type":"var","key":"remote_addr","rejected_code":429,"policy":"'"$RATE_POLICY"'","allow_degradation":true'"$RATE_REDIS"'}}}' + -d '{"plugins":{"limit-count":{"count":'"$GLOBAL_LIMIT_COUNT"',"time_window":'"$GLOBAL_LIMIT_WINDOW"',"key_type":"var","key":"remote_addr","rejected_code":429,"policy":"'"$RATE_POLICY"'","allow_degradation":true'"$RATE_REDIS"'}}}' fi ```