Skip to content

Commit

Permalink
Merge pull request #2173 from murgatroid99/grpc-js_outlier_detection_…
Browse files Browse the repository at this point in the history
…stdev_fix

grpc-js: Outlier detection: Fix standard deviation calculation
  • Loading branch information
murgatroid99 committed Jul 22, 2022
2 parents 6bf3122 + fbf7944 commit 586f7c6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/grpc-js/src/load-balancer-outlier-detection.ts
Expand Up @@ -430,11 +430,12 @@ export class OutlierDetectionLoadBalancer implements LoadBalancer {

// Step 2
const successRateMean = successRates.reduce((a, b) => a + b) / successRates.length;
let successRateVariance = 0;
let successRateDeviationSum = 0;
for (const rate of successRates) {
const deviation = rate - successRateMean;
successRateVariance += deviation * deviation;
successRateDeviationSum += deviation * deviation;
}
const successRateVariance = successRateDeviationSum / successRates.length;
const successRateStdev = Math.sqrt(successRateVariance);
const ejectionThreshold = successRateMean - successRateStdev * (successRateConfig.stdev_factor / 1000);

Expand Down

0 comments on commit 586f7c6

Please sign in to comment.