Skip to content

Commit

Permalink
Merge pull request #9967 from qzhuyan/perf/william/add-tls-common-con…
Browse files Browse the repository at this point in the history
…f-hibernate-after

perf: add tls common conf hibernate after
  • Loading branch information
qzhuyan committed Feb 15, 2023
2 parents 82e040d + 4e6c7bf commit 02f15be
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 1 deletion.
11 changes: 11 additions & 0 deletions apps/emqx/i18n/emqx_schema_i18n.conf
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion apps/emqx/src/emqx.app.src
Expand Up @@ -3,7 +3,7 @@
{id, "emqx"},
{description, "EMQX Core"},
% strict semver, bump manually!
{vsn, "5.0.17"},
{vsn, "5.0.18"},
{modules, []},
{registered, []},
{applications, [
Expand Down
9 changes: 9 additions & 0 deletions apps/emqx/src/emqx_schema.erl
Expand Up @@ -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)
}
)}
].

Expand Down
35 changes: 35 additions & 0 deletions apps/emqx/test/emqx_listeners_SUITE.erl
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions changes/v5.0.18/perf-9967-en.md
@@ -0,0 +1 @@
New common TLS option 'hibernate_after' to reduce memory footprint per idle connecion, default: 5s.
1 change: 1 addition & 0 deletions changes/v5.0.18/perf-9967-zh.md
@@ -0,0 +1 @@
新的通用 TLS 选项 'hibernate_after', 以减少空闲连接的内存占用,默认: 5s 。

0 comments on commit 02f15be

Please sign in to comment.