Merge pull request #6010 from qzhuyan/perf/William/pool-worker-pickup

During the benchmark test of ehttpc, we found the gproc's random pool or round-robin pool doesn't scale well.

This PR makes emqx prefer to use the hash pool.

changed:

retainer pool: from random to hash
connector : from random to hash (default)
bridge : from random to hash (default)
authn_http : from random to hash (example)

unchanged:
worker pool type: hash
broker pool type: hash
resource type: hash
exproto type: hash
dashboard type: hash
This commit is contained in:
William Yang 2021-10-28 09:40:14 +02:00 committed by GitHub
commit 2c69c00906
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 6 additions and 6 deletions

View File

@ -133,7 +133,7 @@ create(#{ method := Method
case emqx_resource:create_local(Unique, case emqx_resource:create_local(Unique,
emqx_connector_http, emqx_connector_http,
Config#{base_url => maps:remove(query, URIMap), Config#{base_url => maps:remove(query, URIMap),
pool_type => random}) of pool_type => hash}) of
{ok, already_created} -> {ok, already_created} ->
{ok, State}; {ok, State};
{ok, _} -> {ok, _} ->

View File

@ -86,7 +86,7 @@ definitions() ->
pool_type => #{ pool_type => #{
type => string, type => string,
enum => [<<"random">>, <<"hash">>], enum => [<<"random">>, <<"hash">>],
example => <<"random">> example => <<"hash">>
}, },
pool_size => #{type => integer}, pool_size => #{type => integer},
enable_pipelining => #{type => boolean}, enable_pipelining => #{type => boolean},

View File

@ -51,7 +51,7 @@
# connect_timeout: "30s" # connect_timeout: "30s"
# max_retries: 3 # max_retries: 3
# retry_interval = "10s" # retry_interval = "10s"
# pool_type = "random" # pool_type = "hash"
# pool_size = 4 # pool_size = 4
# enable_pipelining = true # enable_pipelining = true
# ssl { # ssl {

View File

@ -105,7 +105,7 @@ retry_interval(default) -> <<"1s">>;
retry_interval(_) -> undefined. retry_interval(_) -> undefined.
pool_type(type) -> pool_type(); pool_type(type) -> pool_type();
pool_type(default) -> random; pool_type(default) -> hash;
pool_type(_) -> undefined. pool_type(_) -> undefined.
pool_size(type) -> non_neg_integer(); pool_size(type) -> non_neg_integer();

View File

@ -172,7 +172,7 @@ cast(Msg) ->
%% @private %% @private
worker() -> worker() ->
gproc_pool:pick_worker(?POOL). gproc_pool:pick_worker(?POOL, self()).
run({M, F, A}) -> run({M, F, A}) ->
erlang:apply(M, F, A); erlang:apply(M, F, A);

View File

@ -26,7 +26,7 @@ start_link() ->
supervisor:start_link({local, ?MODULE}, ?MODULE, []). supervisor:start_link({local, ?MODULE}, ?MODULE, []).
init([]) -> init([]) ->
PoolSpec = emqx_pool_sup:spec([emqx_retainer_pool, random, emqx_vm:schedulers(), PoolSpec = emqx_pool_sup:spec([emqx_retainer_pool, hash, emqx_vm:schedulers(),
{emqx_retainer_pool, start_link, []}]), {emqx_retainer_pool, start_link, []}]),
{ok, {{one_for_one, 10, 3600}, {ok, {{one_for_one, 10, 3600},
[#{id => retainer, [#{id => retainer,