erlang - why lager design this way? -


When I use leगर I get a problem. In the leaguer source code, the lager_backend_throttle.erl file

  handle_event ({log, _Message}, state) - & gt; {message_queue_len, Len} = erlang: process_info (self (), message_queue_len), case {le & gt; State # state.hwm, state # state.async} {true, true} -> gt; %% need to flip in sync mode lager_config: set (async, false), {ok, state # state {async = false}}; {False, false} - & gt; %% need to flip on Async mode lager_config: set (async, true), {ok, State # state {async = true}}; _ - & gt; There is no need to change anything at the end of {well, state};   

When message_queue_len is over thresholds, it will flip in sync mode.

When message_queue_len is less than Thershold, it will flip in async mode.

I think that when there is a lot of message, then this message should be converted to Async so that the message can be processed more quickly soon. Why laser designs this way?

I think the reason is message length in the message_queue, if there are too many messages, then the process may crash, then changing the sending sender mode reduces the speed of sending the message?

I got the answer on the gitub.

Prior to Ligar 2.0, the gene_evolution on the core of large is fully operated in synchronous mode. Asynchronous mode is fast, but there is no security against message queue overload. In Liger 2.0, gen_event takes a hybrid approach. It toggles its mailbox size between synchronous and asynchronous messages based on the size of the mailbox and will use async messaging until the mailbox has more than 20 messages. {async_threshold, 20}, async_threshold_window, 5} the point at which synchronous messages will be used, and switch back to Asynchronous, when size decreases to 20 - 5 = 15.

If you want to disable this behavior, set it to 'Undefined', it misses the mailbox faster than the limit and misses a small number to prevent problems from being created. In general, Larjar should fast as fast as he should in messages, so behind 20 should be relatively extraordinary.

If you want to limit the number of messages per second permitted by error_logger, which is a good idea, if you want to weather the flood of messages when you crash many related processes, then you You can set a limit:

{error_logger_hwm, 50} It's probably best to keep this number short.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -