Skip to content

Remove consumer bias & allow queues under max load to drain quickly #1378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 1, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions src/rabbit_amqqueue_process.erl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

-define(SYNC_INTERVAL, 200). %% milliseconds
-define(RAM_DURATION_UPDATE_INTERVAL, 5000).
-define(CONSUMER_BIAS_RATIO, 1.1). %% i.e. consume 10% faster

-export([info_keys/0]).

Expand Down Expand Up @@ -969,26 +968,26 @@ emit_consumer_deleted(ChPid, ConsumerTag, QName) ->

%%----------------------------------------------------------------------------

prioritise_call(Msg, _From, _Len, State) ->
prioritise_call(Msg, _From, _Len, _State) ->
case Msg of
info -> 9;
{info, _Items} -> 9;
consumers -> 9;
stat -> 7;
{basic_consume, _, _, _, _, _, _, _, _, _} -> consumer_bias(State);
{basic_cancel, _, _, _} -> consumer_bias(State);
{basic_consume, _, _, _, _, _, _, _, _, _} -> 1;
{basic_cancel, _, _, _} -> 1;
_ -> 0
end.

prioritise_cast(Msg, _Len, State) ->
prioritise_cast(Msg, _Len, _State) ->
case Msg of
delete_immediately -> 8;
{set_ram_duration_target, _Duration} -> 8;
{set_maximum_since_use, _Age} -> 8;
{run_backing_queue, _Mod, _Fun} -> 6;
{ack, _AckTags, _ChPid} -> 3; %% [1]
{resume, _ChPid} -> 2;
{notify_sent, _ChPid, _Credit} -> consumer_bias(State);
{notify_sent, _ChPid, _Credit} -> 1;
_ -> 0
end.

Expand All @@ -1001,13 +1000,6 @@ prioritise_cast(Msg, _Len, State) ->
%% about. Finally, we prioritise ack over resume since it should
%% always reduce memory use.

consumer_bias(#q{backing_queue = BQ, backing_queue_state = BQS}) ->
case BQ:msg_rates(BQS) of
{0.0, _} -> 0;
{Ingress, Egress} when Egress / Ingress < ?CONSUMER_BIAS_RATIO -> 1;
{_, _} -> 0
end.

prioritise_info(Msg, _Len, #q{q = #amqqueue{exclusive_owner = DownPid}}) ->
case Msg of
{'DOWN', _, process, DownPid, _} -> 8;
Expand Down