Skip to content

Commit e9b4e2c

Browse files
committed
feat: raise default sizes for non-evictable shared dicts
The prometheus-metrics, service-discovery, and tracing shared dicts reject writes and drop data when full, with no self-healing eviction. Their previous defaults overflow on medium and large deployments, causing silently missing metrics, unresolved upstream nodes, or lost trace spans that are hard to diagnose. Raise the defaults so a typical deployment works without manual tuning: - prometheus-metrics: 15m/10m -> 256m - kubernetes / consul discovery shared_size: 1m -> 64m - nacos / nacos-stream discovery: 10m -> 64m - tracing_buffer: 10m -> 32m An explicit size in config.yaml (or a discovery config's shared_size) always overrides the default, so deployments that already tune these are unaffected. Signed-off-by: Nic <qianyong@api7.ai>
1 parent 100be4c commit e9b4e2c

9 files changed

Lines changed: 21 additions & 21 deletions

File tree

apisix/cli/config.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ local _M = {
103103
},
104104
meta = {
105105
lua_shared_dict = {
106-
["prometheus-metrics"] = "15m",
106+
["prometheus-metrics"] = "256m",
107107
["prometheus-cache"] = "10m",
108108
["standalone-config"] = "10m",
109109
["status-report"] = "1m",
@@ -162,7 +162,7 @@ local _M = {
162162
["internal-status"] = "10m",
163163
["plugin-limit-req"] = "10m",
164164
["plugin-limit-count"] = "10m",
165-
["prometheus-metrics"] = "10m",
165+
["prometheus-metrics"] = "256m",
166166
["plugin-limit-conn"] = "10m",
167167
["worker-events"] = "10m",
168168
["lrucache-lock"] = "10m",
@@ -177,7 +177,7 @@ local _M = {
177177
["plugin-graphql-limit-count-reset-header"] = "10m",
178178
["plugin-ai-rate-limiting"] = "10m",
179179
["plugin-ai-rate-limiting-reset-header"] = "10m",
180-
tracing_buffer = "10m",
180+
tracing_buffer = "32m",
181181
["plugin-api-breaker"] = "10m",
182182
["etcd-cluster-health-check"] = "10m",
183183
discovery = "1m",

apisix/cli/ngx_tpl.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ lua {
7777
{% if status then %}
7878
lua_shared_dict status-report {* meta.lua_shared_dict["status-report"] *};
7979
{% end %}
80-
lua_shared_dict nacos 10m;
80+
lua_shared_dict nacos 64m;
8181
lua_shared_dict upstream-healthcheck {* meta.lua_shared_dict["upstream-healthcheck"] *};
8282
}
8383
@@ -149,7 +149,7 @@ stream {
149149
lua_shared_dict lrucache-lock-stream {* stream.lua_shared_dict["lrucache-lock-stream"] *};
150150
lua_shared_dict etcd-cluster-health-check-stream {* stream.lua_shared_dict["etcd-cluster-health-check-stream"] *};
151151
lua_shared_dict worker-events-stream {* stream.lua_shared_dict["worker-events-stream"] *};
152-
lua_shared_dict nacos-stream 10m;
152+
lua_shared_dict nacos-stream 64m;
153153
154154
{% if enabled_discoveries["tars"] then %}
155155
lua_shared_dict tars-stream {* stream.lua_shared_dict["tars-stream"] *};

apisix/cli/ops.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,7 @@ Please modify "admin_key" in conf/config.yaml .
908908
end
909909

910910
local consul_conf = yaml_conf.discovery["consul"]
911-
sys_conf["discovery_shared_dicts"]["consul"] = consul_conf.shared_size or "10m"
911+
sys_conf["discovery_shared_dicts"]["consul"] = consul_conf.shared_size or "64m"
912912
end
913913

914914
-- fix up lua path

apisix/discovery/consul/schema.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ return {
2727
shared_size = {
2828
type = "string",
2929
pattern = [[^[1-9][0-9]*m$]],
30-
default = "1m",
30+
default = "64m",
3131
},
3232
token = {type = "string", default = ""},
3333
fetch_interval = {type = "integer", minimum = 1, default = 3},

apisix/discovery/kubernetes/schema.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ local default_weight_schema = {
102102
local shared_size_schema = {
103103
type = "string",
104104
pattern = [[^[1-9][0-9]*m$]],
105-
default = "1m",
105+
default = "64m",
106106
}
107107

108108
local watch_endpoint_slices_schema = {

docs/en/latest/discovery/kubernetes.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ discovery:
9090
first="a",second="b"
9191
9292
# reserved lua shared memory size,1m memory can store about 1000 pieces of endpoint
93-
shared_size: 1m #default 1m
93+
shared_size: 64m #default 64m
9494

9595
# if watch_endpoint_slices setting true, watch apiserver with endpointslices instead of endpoints
9696
watch_endpoint_slices: false #default false
@@ -222,7 +222,7 @@ discovery:
222222
first="a",second="b"
223223
224224
# reserved lua shared memory size,1m memory can store about 1000 pieces of endpoint
225-
shared_size: 1m #default 1m
225+
shared_size: 64m #default 64m
226226

227227
# if watch_endpoint_slices setting true, watch apiserver with endpointslices instead of endpoints
228228
watch_endpoint_slices: false #default false
@@ -402,7 +402,7 @@ Which will yield the following response:
402402
"port": "6443",
403403
"schema": "https"
404404
},
405-
"shared_size": "1m"
405+
"shared_size": "64m"
406406
}
407407
]
408408
}

docs/zh/latest/discovery/kubernetes.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ discovery:
9090
first="a",second="b"
9191
9292
# reserved lua shared memory size, 1m memory can store about 1000 pieces of endpoint
93-
shared_size: 1m #default 1m
93+
shared_size: 64m #default 64m
9494

9595
# if watch_endpoint_slices setting true, watch apiserver with endpointslices instead of endpoints
9696
watch_endpoint_slices: false #default false
@@ -221,7 +221,7 @@ discovery:
221221
first="a",second="b"
222222
223223
# reserved lua shared memory size,1m memory can store about 1000 pieces of endpoint
224-
shared_size: 1m #default 1m
224+
shared_size: 64m #default 64m
225225

226226
# if watch_endpoint_slices setting true, watch apiserver with endpointslices instead of endpoints
227227
watch_endpoint_slices: false #default false
@@ -399,7 +399,7 @@ GET /v1/discovery/kubernetes/dump
399399
"port": "6443",
400400
"schema": "https"
401401
},
402-
"shared_size": "1m"
402+
"shared_size": "64m"
403403
}
404404
]
405405
}

t/cli/test_kubernetes.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ if ! grep "env TOKEN_ENV" conf/nginx.conf; then
4545
exit 1
4646
fi
4747

48-
if ! grep "lua_shared_dict kubernetes 1m;" conf/nginx.conf; then
48+
if ! grep "lua_shared_dict kubernetes 64m;" conf/nginx.conf; then
4949
echo "kubernetes discovery lua_shared_dict inject failed"
5050
exit 1
5151
fi
@@ -100,7 +100,7 @@ if ! grep "env PRO_TOKEN" conf/nginx.conf; then
100100
exit 1
101101
fi
102102

103-
if ! grep "lua_shared_dict kubernetes-dev 1m;" conf/nginx.conf; then
103+
if ! grep "lua_shared_dict kubernetes-dev 64m;" conf/nginx.conf; then
104104
echo "kubernetes discovery lua_shared_dict inject failed"
105105
exit 1
106106
fi

t/kubernetes/discovery/kubernetes.t

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ GET /compare
144144
"token": "${KUBERNETES_CLIENT_TOKEN}"
145145
},
146146
"watch_endpoint_slices": false,
147-
"shared_size": "1m",
147+
"shared_size": "64m",
148148
"default_weight": 50
149149
}
150150
--- more_headers
@@ -179,7 +179,7 @@ GET /compare
179179
"token": "${KUBERNETES_CLIENT_TOKEN}"
180180
},
181181
"watch_endpoint_slices": false,
182-
"shared_size": "1m",
182+
"shared_size": "64m",
183183
"default_weight": 50
184184
}
185185
--- more_headers
@@ -251,7 +251,7 @@ GET /compare
251251
"token": "${KUBERNETES_CLIENT_TOKEN}"
252252
},
253253
"watch_endpoint_slices": false,
254-
"shared_size": "1m",
254+
"shared_size": "64m",
255255
"default_weight": 33
256256
}
257257
--- more_headers
@@ -304,7 +304,7 @@ GET /compare
304304
},
305305
"watch_endpoint_slices": false,
306306
"default_weight": 50,
307-
"shared_size": "1m"
307+
"shared_size": "64m"
308308
},
309309
{
310310
"id": "release",
@@ -354,7 +354,7 @@ GET /compare
354354
"token": "${KUBERNETES_CLIENT_TOKEN}"
355355
},
356356
"watch_endpoint_slices": true,
357-
"shared_size": "1m",
357+
"shared_size": "64m",
358358
"default_weight": 33
359359
}
360360
--- more_headers

0 commit comments

Comments
 (0)