Merge pull request #9967 from qzhuyan/perf/william/add-tls-common-conf-hibernate-after

perf: add tls common conf hibernate after
This commit is contained in:
William Yang 2023-02-15 12:02:05 +01:00 committed by GitHub
commit 02f15be20f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 58 additions and 1 deletions

View File

@ -1495,6 +1495,17 @@ In case PSK cipher suites are intended, make sure to configure
}
}
common_ssl_opts_schema_hibernate_after {
desc {
en: """ Hibernate the SSL process after idling for amount of time reducing its memory footprint. """
zh: """ 在闲置一定时间后休眠 SSL 进程,减少其内存占用。"""
}
label: {
en: "hibernate after"
zh: "闲置多久后休眠"
}
}
ciphers_schema_common {
desc {
en: """This config holds TLS cipher suite names separated by comma,

View File

@ -3,7 +3,7 @@
{id, "emqx"},
{description, "EMQX Core"},
% strict semver, bump manually!
{vsn, "5.0.17"},
{vsn, "5.0.18"},
{modules, []},
{registered, []},
{applications, [

View File

@ -1929,6 +1929,15 @@ common_ssl_opts_schema(Defaults) ->
default => Df("secure_renegotiate", true),
desc => ?DESC(common_ssl_opts_schema_secure_renegotiate)
}
)},
{"hibernate_after",
sc(
duration(),
#{
default => Df("hibernate_after", "5s"),
desc => ?DESC(common_ssl_opts_schema_hibernate_after)
}
)}
].

View File

@ -138,6 +138,41 @@ t_restart_listeners(_) ->
ok = emqx_listeners:restart(),
ok = emqx_listeners:stop().
t_restart_listeners_with_hibernate_after_disabled(_Config) ->
OldLConf = emqx_config:get([listeners]),
maps:foreach(
fun(LType, Listeners) ->
maps:foreach(
fun(Name, Opts) ->
case maps:is_key(ssl_options, Opts) of
true ->
emqx_config:put(
[
listeners,
LType,
Name,
ssl_options,
hibernate_after
],
undefined
);
_ ->
skip
end
end,
Listeners
)
end,
OldLConf
),
ok = emqx_listeners:start(),
ok = emqx_listeners:stop(),
%% flakyness: eaddrinuse
timer:sleep(timer:seconds(2)),
ok = emqx_listeners:restart(),
ok = emqx_listeners:stop(),
emqx_config:put([listeners], OldLConf).
t_max_conns_tcp(_) ->
%% Note: Using a string representation for the bind address like
%% "127.0.0.1" does not work

View File

@ -0,0 +1 @@
New common TLS option 'hibernate_after' to reduce memory footprint per idle connecion, default: 5s.

View File

@ -0,0 +1 @@
新的通用 TLS 选项 'hibernate_after' 以减少空闲连接的内存占用,默认: 5s 。