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