Skip to content

Commit

Permalink
Netflix#147: let AIMD grow by configurable amount
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorPerikov committed Dec 3, 2019
1 parent f8c115b commit 84d8e7b
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public static class Builder {
private int minLimit = 20;
private int initialLimit = 20;
private int maxLimit = 200;
private int increase = 1;
private double backoffRatio = 0.9;
private long timeout = DEFAULT_TIMEOUT;

Expand All @@ -55,6 +56,12 @@ public Builder backoffRatio(double backoffRatio) {
return this;
}

public Builder increaseBy(int increase) {
Preconditions.checkArgument(increase >= 1, "Increase value must be >= 1");
this.increase = increase;
return this;
}

/**
* Timeout threshold that when exceeded equates to a drop.
* @param timeout
Expand All @@ -75,14 +82,16 @@ public AIMDLimit build() {
public static Builder newBuilder() {
return new Builder();
}


private final int increase;
private final double backoffRatio;
private final long timeout;
private final int minLimit;
private final int maxLimit;

private AIMDLimit(Builder builder) {
super(builder.initialLimit);
this.increase = builder.increase;
this.backoffRatio = builder.backoffRatio;
this.timeout = builder.timeout;
this.maxLimit = builder.maxLimit;
Expand All @@ -96,7 +105,7 @@ protected int _update(long startTime, long rtt, int inflight, boolean didDrop) {
if (didDrop || rtt > timeout) {
currentLimit = (int) (currentLimit * backoffRatio);
} else if (inflight * 2 >= currentLimit) {
currentLimit = currentLimit + 1;
currentLimit = currentLimit + increase;
}

if (currentLimit >= maxLimit) {
Expand Down

0 comments on commit 84d8e7b

Please sign in to comment.