Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
8672b2f3
Commit
8672b2f3
authored
Feb 06, 2026
by
yangjianbo
Browse files
chore(gateway): 提升 max_idle_conns 并补齐 env
parent
de753a14
Changes
4
Show whitespace changes
Inline
Side-by-side
backend/internal/config/config.go
View file @
8672b2f3
...
...
@@ -886,7 +886,7 @@ func setDefaults() {
viper
.
SetDefault
(
"gateway.max_body_size"
,
int64
(
100
*
1024
*
1024
))
viper
.
SetDefault
(
"gateway.connection_pool_isolation"
,
ConnectionPoolIsolationAccountProxy
)
// HTTP 上游连接池配置(针对 5000+ 并发用户优化)
viper
.
SetDefault
(
"gateway.max_idle_conns"
,
2
4
0
)
// 最大空闲连接总数(
HTTP/2 场景默认
)
viper
.
SetDefault
(
"gateway.max_idle_conns"
,
2
56
0
)
// 最大空闲连接总数(
高并发场景可调大
)
viper
.
SetDefault
(
"gateway.max_idle_conns_per_host"
,
120
)
// 每主机最大空闲连接(HTTP/2 场景默认)
viper
.
SetDefault
(
"gateway.max_conns_per_host"
,
1024
)
// 每主机最大连接数(含活跃;流式/HTTP1.1 场景可调大,如 2400+)
viper
.
SetDefault
(
"gateway.idle_conn_timeout_seconds"
,
90
)
// 空闲连接超时(秒)
...
...
deploy/.env.example
View file @
8672b2f3
...
...
@@ -171,6 +171,10 @@ RATE_LIMIT_OVERLOAD_COOLDOWN_MINUTES=10
# -----------------------------------------------------------------------------
# 上游连接池:每主机最大连接数(默认 1024;流式/HTTP1.1 场景可调大,如 2400/4096)
GATEWAY_MAX_CONNS_PER_HOST=1024
# 上游连接池:最大空闲连接总数(默认 2560;账号/代理隔离 + 高并发场景可调大)
GATEWAY_MAX_IDLE_CONNS=2560
# 上游连接池:每主机最大空闲连接(默认 120)
GATEWAY_MAX_IDLE_CONNS_PER_HOST=120
# 粘性会话最大排队长度
GATEWAY_SCHEDULING_STICKY_SESSION_MAX_WAITING=3
# 粘性会话等待超时(时间段,例如 45s)
...
...
deploy/config.example.yaml
View file @
8672b2f3
...
...
@@ -155,7 +155,7 @@ gateway:
# HTTP 上游连接池配置(HTTP/2 + 多代理场景默认值)
# Max idle connections across all hosts
# 所有主机的最大空闲连接数
max_idle_conns
:
2
4
0
max_idle_conns
:
2
56
0
# Max idle connections per host
# 每个主机的最大空闲连接数
max_idle_conns_per_host
:
120
...
...
deploy/docker-compose-aicodex.yml
View file @
8672b2f3
...
...
@@ -66,6 +66,8 @@ services:
# =======================================================================
# Gateway Configuration
# =======================================================================
-
GATEWAY_MAX_IDLE_CONNS=${GATEWAY_MAX_IDLE_CONNS:-2560}
-
GATEWAY_MAX_IDLE_CONNS_PER_HOST=${GATEWAY_MAX_IDLE_CONNS_PER_HOST:-120}
-
GATEWAY_MAX_CONNS_PER_HOST=${GATEWAY_MAX_CONNS_PER_HOST:-1024}
# =======================================================================
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment