Skip to content

Commit

Permalink
Use bitrate instead of videostreams for load balancing.
Browse files Browse the repository at this point in the history
  • Loading branch information
bgrozev committed May 9, 2019
1 parent 6f5f945 commit 159ade2
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/main/java/org/jitsi/jicofo/Bridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ class Bridge
*/
private int videoStreamCountDiff = 0;

/**
* The last reported bitrate in Kbps.
*/
private int lastReportedBitrateKbps = 0;

/**
* Holds bridge version (if known - not all bridge version are capable of
* reporting it).
Expand Down Expand Up @@ -154,6 +159,13 @@ void setStats(ColibriStatsExtension stats)
setVideoStreamCount(videoStreamCount);
}

Integer bitrateUpKbps = stats.getValueAsInt(STAT_NAME_BITRATE_UP);
Integer bitrateDownKbps = stats.getValueAsInt(STAT_NAME_BITRATE_DOWN);
if (bitrateUpKbps != null && bitrateDownKbps != null)
{
lastReportedBitrateKbps = bitrateDownKbps + bitrateUpKbps;
}

setIsOperational(!Boolean.valueOf(stats.getValueAsString(
JigasiDetector.STAT_NAME_SHUTDOWN_IN_PROGRESS)));
}
Expand Down Expand Up @@ -249,7 +261,8 @@ private void verifyFailureThreshold()
}

/**
* The least value is returned the least the bridge is loaded.
* The least value is returned the least the bridge is loaded. Currently
* we use the bitrate to estimate load.
* <p>
* {@inheritDoc}
*/
Expand All @@ -268,8 +281,7 @@ else if (!meOperational && otherOperational)
return 1;
}

return this.getEstimatedVideoStreamCount()
- o.getEstimatedVideoStreamCount();
return this.lastReportedBitrateKbps - o.lastReportedBitrateKbps;
}

private int getEstimatedVideoStreamCount()
Expand Down

0 comments on commit 159ade2

Please sign in to comment.