用 Spring Boot 搭建完 Spring Cloud 微服务项目后,又用 Nginx 为 Spring Gateway 做了负载均衡,其中做了并发限制和每秒连接数限制,Nginx 的配置如下:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
# 开启令牌桶 - 每秒新增 100 个令牌
limit_req_zone $binary_remote_addr zone