-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf(router): increase lua_regex_cache_max_entries
and show warning if too small
#9624
Conversation
lua_regex_cache_max_entries
and show warning if too smalllua_regex_cache_max_entries
and show warning if too small
lua_regex_cache_max_entries
and show warning if too smalllua_regex_cache_max_entries
and show warning if too small
🚀 Performance test resultTest Suite: 01-rps 02-flamegraph (baseline,single_route,simple) Click to expand
Download Artifacts for detailed results and interactive SVG flamegraphs. |
324d3e9
to
3734160
Compare
🚀 Performance test resultTest Suite: 01-rps 02-flamegraph (baseline,single_route,simple) Click to expand
Download Artifacts for detailed results and interactive SVG flamegraphs. |
🚀 Performance test resultTest Suite: 01-rps 02-flamegraph (baseline,single_route,simple) Click to expand
Download Artifacts for detailed results and interactive SVG flamegraphs. |
🚀 Performance test resultTest Suite: 01-rps 02-flamegraph (baseline,single_route,simple) Click to expand
Download Artifacts for detailed results and interactive SVG flamegraphs. |
🚀 Performance test resultTest Suite: 01-rps 02-flamegraph (baseline,single_route,simple) Click to expand
Download Artifacts for detailed results and interactive SVG flamegraphs. |
kong/router/traditional.lua
Outdated
@@ -1448,6 +1450,20 @@ function _M.new(routes, cache, cache_neg) | |||
local match_sources = not isempty(plain_indexes.sources) | |||
local match_destinations = not isempty(plain_indexes.destinations) | |||
|
|||
-- warning about the regex cache size being too small | |||
if not lua_regex_cache_max_entries then | |||
lua_regex_cache_max_entries = kong.configuration.nginx_http_lua_regex_cache_max_entries or 1024 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we default here to 8192 too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems non-sense because OpenResty's default value of lua_regex_cache_max_entries
is 1024
(https://github.com/openresty/lua-nginx-module/blob/master/README.markdown#lua_regex_cache_max_entries), we set the nginx_http_lua_regex_cache_max_entries
to 8192
, but the user could overwrite it.
ae2eb90
to
4e29ac0
Compare
🚀 Performance test resultTest Suite: 01-rps 02-flamegraph (baseline,single_route,simple) Click to expand
Download Artifacts for detailed results and interactive SVG flamegraphs. |
🚀 Performance test resultTest Suite: 01-rps 02-flamegraph (baseline,single_route,simple) Click to expand
Download Artifacts for detailed results and interactive SVG flamegraphs. |
🚀 Performance test resultTest Suite: 01-rps 02-flamegraph (baseline,single_route,simple) Click to expand
Download Artifacts for detailed results and interactive SVG flamegraphs. |
kong/router/traditional.lua
Outdated
and tonumber(kong.configuration.nginx_http_lua_regex_cache_max_entries) or 1024 | ||
end | ||
|
||
if worker_id() == 0 and regex_uris[0] > lua_regex_cache_max_entries then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should also be checking for regex_uris[0] * 2 > lua_regex_cache_max_entries
here, if user sets lua_regex_cache_max_entries
to be exactly regex_uris[0]
we can still expect issues regarding regex cache trashing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, done.
58ccaa3
to
546e4fd
Compare
🚀 Performance test resultTest Suite: 01-rps 02-flamegraph (baseline,single_route,simple) Click to expand
Download Artifacts for detailed results and interactive SVG flamegraphs. |
🚀 Performance test resultTest Suite: 01-rps 02-flamegraph (baseline,single_route,simple) Click to expand
Download Artifacts for detailed results and interactive SVG flamegraphs. |
🚀 Performance test resultTest Suite: 01-rps 02-flamegraph (baseline,single_route,simple) Click to expand
Download Artifacts for detailed results and interactive SVG flamegraphs. |
🚀 Performance test resultTest Suite: 01-rps 02-flamegraph (baseline,single_route,simple) Click to expand
Download Artifacts for detailed results and interactive SVG flamegraphs. |
Hi @mayocream , |
Summary
When a user sets too many regex routes and
lua_regex_cache_max_entries
is set too low (or kept at default 1024), a performance issue might occur due to regex trashing.OpenResty claims that it will emit a warning when the limit has been exceeded, but it doesn't.
Fix FTI-4455