在 Linux 上部署的 MinIO 本身不提供原生的“限流”功能(如 QPS、带宽限制),但可以通过 系统层或代理层 来实现限流。下面按常见场景给你几种可行方案。
如果你是通过 Nginx 访问 MinIO,可以用 Nginx 做限流。
http {
limit_req_zone $binary_remote_addr zone=minio_limit:10m rate=10r/s;
server {
listen 80;
server_name minio.example.com;
location / {
limit_req zone=minio_limit burst=20 nodelay;
proxy_pass http://127.0.0.1:9000;
}
}
}
✅ 效果:
location / {
proxy_pass http://127.0.0.1:9000;
# 限制下载带宽
proxy_limit_rate 1m;
# 限制上传带宽
client_max_body_size 100m;
}
✅ 适合限制大文件上传/下载速度
适合 不通过 Nginx,直接访问 MinIO 的场景。
假设 MinIO 使用 9000 端口:
# 添加根队列
tc qdisc add dev eth0 root handle 1: htb
# 创建类(限速 10Mbps)
tc class add dev eth0 parent 1: classid 1:10 htb rate 10mbit
# 过滤 9000 端口
tc filter add dev eth0 protocol ip parent 1:0 prio 1 u32 \
match ip dport 9000 0xffff flowid 1:10
✅ 优点:不依赖应用
❌ 缺点:配置复杂,影响所有访问
iptables -A INPUT -p tcp --dport 9000 \
-m connlimit --connlimit-above 10 -j DROP
✅ 限制单个 IP 到 MinIO 的最大连接数
MinIO 本身支持:
mc admin bucket quota set myminio/mybucket --hard 10GB
✅ 防止存储爆炸
❌ 不是流量限流
| 需求 | 推荐方式 |
|---|---|
| 限制 QPS | Nginx limit_req |
| 限制带宽 | Nginx proxy_limit_rate |
| 系统级限流 | tc |
| 限制连接数 | iptables |
| 防止存储滥用 | MinIO Quota |
如果你愿意,可以告诉我:
我可以给你 直接可用的配置。