-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[4.3] Listener federators and memory improvements (#6297)
* [4.3] Listener federators and memory improvements Prior, when a gen_listener needed to federate its queue and bindings to other zones, it would start_link the listener_federator (and trap exits). However, should a listener_federator process actually exit, the parent gen_listener would receive the EXIT message but failed to have a handle_info clause to restart the process. Introduce a sofo supervisor for starting listener_federator processes and restart them if they die unexpectedly (non-normal exits). Secondly, introduce memory consumption checks and GC gen_listeners when they exceed 100K in total_heap_size. In addition, copy the binary payloads as they arrive off the AMQP channel has shown to decelerate the memory growth as the original binary can be garbage collected sooner and not count against the gen_listener's "old" heap. All told, these manual GC runs appear to be minimal and only affect long-running and busy gen_listeners; even fewer runs needed to release memory after the binary:copy/1 introduction. * edoc * just ok * fun police * monitor parent and terminate if parent dies
- Loading branch information
1 parent
ff5c058
commit b918e2b
Showing
7 changed files
with
219 additions
and
83 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
%%%----------------------------------------------------------------------------- | ||
%%% @copyright (C) 2012-2020, 2600Hz | ||
%%% @doc | ||
%%% @end | ||
%%%----------------------------------------------------------------------------- | ||
-module(kz_amqp_federated_listeners_sup). | ||
|
||
-behaviour(supervisor). | ||
|
||
-export([start_link/0 | ||
,start_child/3 | ||
,init/1 | ||
]). | ||
|
||
-include("kz_amqp_util.hrl"). | ||
|
||
-define(CHILDREN, [?WORKER_TYPE('listener_federator', 'transient')]). | ||
|
||
-spec start_link() -> kz_types:startlink_ret(). | ||
start_link() -> | ||
supervisor:start_link({'local', ?MODULE}, ?MODULE, []). | ||
|
||
-spec start_child(pid(), kz_term:ne_binary(), kz_term:proplist()) -> kz_types:sup_startchild_ret(). | ||
start_child(Parent, Broker, FederateParams) -> | ||
ParentCallId = kz_util:get_callid(), | ||
supervisor:start_child(?MODULE, [Parent, ParentCallId, Broker, FederateParams]). | ||
|
||
-spec init(any()) -> kz_types:sup_init_ret(). | ||
init([]) -> | ||
RestartStrategy = 'simple_one_for_one', | ||
MaxRestarts = 5, | ||
MaxSecondsBetweenRestarts = 10, | ||
SupFlags = {RestartStrategy, MaxRestarts, MaxSecondsBetweenRestarts}, | ||
|
||
{'ok', {SupFlags, ?CHILDREN}}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters