#!/usr/bin/env bash # Concurrent load: expect 429 (not 503) once the burst budget is exhausted. set -uo pipefail HOST='Host: demo.test' echo "== 600 个动态请求,并发 40 ==" codes=$(seq 1 600 | xargs -P 40 -I{} curl -s -o /dev/null -w '%{http_code}\n' -H "$HOST" "http://127.0.0.1/p{}") echo "$codes" | sort | uniq -c | sort -rn echo "== 600 个静态请求,并发 40(不应限速) ==" codes=$(seq 1 600 | xargs -P 40 -I{} curl -s -o /dev/null -w '%{http_code}\n' -H "$HOST" "http://127.0.0.1/s{}.css") echo "$codes" | sort | uniq -c | sort -rn sleep 6 echo "== 冷却后正常请求 ==" curl -s -o /dev/null -w '%{http_code}\n' -H "$HOST" http://127.0.0.1/ echo "== nginx 最近错误 ==" tail -3 /var/log/nginx/error.log