Add log_burst_limit_* options

On our ejabberd deployment we were sometimes seeing more than 500
msgs/sec of legitimate traffic, however this was getting silently
dropped. Provide config options to enable this limit to be configured
from the config file.
This commit is contained in:
Mark Zealey 2022-07-19 10:48:37 +01:00
parent 9b647a7afe
commit eba14f4746
4 changed files with 34 additions and 1 deletions

View File

@ -266,13 +266,17 @@ start(Level) ->
ErrorLog = filename:join([Dir, "error.log"]),
LogRotateSize = get_integer_env(log_rotate_size, 10*1024*1024),
LogRotateCount = get_integer_env(log_rotate_count, 1),
LogBurstLimitWindowTime = get_integer_env(log_burst_limit_window_time, 1000),
LogBurstLimitCount = get_integer_env(log_burst_limit_count, 500),
Config = #{max_no_bytes => LogRotateSize,
max_no_files => LogRotateCount,
filesync_repeat_interval => no_repeat,
file_check => 1000,
sync_mode_qlen => 1000,
drop_mode_qlen => 1000,
flush_qlen => 5000},
flush_qlen => 5000,
burst_limit_window_time => LogBurstLimitWindowTime,
burst_limit_max_count => LogBurstLimitCount},
FmtConfig = #{legacy_header => false,
time_designator => $ ,
max_size => 100*1024,

View File

@ -72,6 +72,8 @@
-export([ldap_tls_verify/0, ldap_tls_verify/1]).
-export([ldap_uids/0, ldap_uids/1]).
-export([listen/0]).
-export([log_burst_limit_count/0]).
-export([log_burst_limit_window_time/0]).
-export([log_rotate_count/0]).
-export([log_rotate_size/0]).
-export([loglevel/0]).
@ -583,6 +585,14 @@ ldap_uids(Host) ->
listen() ->
ejabberd_config:get_option({listen, global}).
-spec log_burst_limit_count() -> pos_integer().
log_burst_limit_count() ->
ejabberd_config:get_option({log_burst_limit_count, global}).
-spec log_burst_limit_window_time() -> pos_integer().
log_burst_limit_window_time() ->
ejabberd_config:get_option({log_burst_limit_window_time, global}).
-spec log_rotate_count() -> non_neg_integer().
log_rotate_count() ->
ejabberd_config:get_option({log_rotate_count, global}).

View File

@ -222,6 +222,10 @@ opt_type(log_rotate_count) ->
econf:non_neg_int();
opt_type(log_rotate_size) ->
econf:pos_int(infinity);
opt_type(log_burst_limit_window_time) ->
econf:timeout(second);
opt_type(log_burst_limit_count) ->
econf:pos_int();
opt_type(loglevel) ->
fun(N) when is_integer(N) ->
(econf:and_then(
@ -576,6 +580,8 @@ options() ->
{listen, []},
{log_rotate_count, 1},
{log_rotate_size, 10*1024*1024},
{log_burst_limit_window_time, timer:seconds(1)},
{log_burst_limit_count, 500},
{max_fsm_queue, undefined},
{modules, []},
{negotiation_timeout, timer:seconds(30)},
@ -722,6 +728,8 @@ globals() ->
loglevel,
log_rotate_count,
log_rotate_size,
log_burst_limit_count,
log_burst_limit_window_time,
negotiation_timeout,
net_ticktime,
new_sql_schema,

View File

@ -815,6 +815,17 @@ doc() ->
?T("The size (in bytes) of a log file to trigger rotation. "
"If set to 'infinity', log rotation is disabled. "
"The default value is '10485760' (that is, 10 Mb).")}},
{log_burst_limit_count,
#{value => ?T("Number"),
desc =>
?T("The number of messages to accept in "
"`log_burst_limit_window_time` period before starting to "
"drop them. Default 500")}},
{log_burst_limit_window_time,
#{value => ?T("Number"),
desc =>
?T("The time period to rate-limit log messages "
"by. Defaults to 1 second.")}},
{max_fsm_queue,
#{value => ?T("Size"),
desc =>