File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ type ConcurrencyMetrics struct {
42
42
Lock sync.Mutex // Lock for response time variability metrics
43
43
StdDevThreshold float64 // Maximum acceptable standard deviation for adjusting concurrency
44
44
DebounceScaleDownCount int // Counter to manage scale down actions after consecutive triggers
45
+ DebounceScaleUpCount int // Counter to manage scale up actions after consecutive triggers
45
46
}
46
47
ResponseCodeMetrics struct {
47
48
ErrorRate float64 // Error rate calculated as (TotalRateLimitErrors + 5xxErrors) / TotalRequests
Original file line number Diff line number Diff line change @@ -225,7 +225,7 @@ func (ch *ConcurrencyHandler) MonitorResponseTimeVariability(responseTime time.D
225
225
stdDev := calculateStdDev (responseTimes )
226
226
averageResponseTime := calculateAverage (responseTimes )
227
227
228
- // Multi-factor check before scaling down
228
+ // Check if conditions suggest a need to scale down
229
229
if stdDev > ch .Metrics .ResponseTimeVariability .StdDevThreshold && averageResponseTime > AcceptableAverageResponseTime {
230
230
ch .Metrics .ResponseTimeVariability .DebounceScaleDownCount ++
231
231
if ch .Metrics .ResponseTimeVariability .DebounceScaleDownCount >= debounceScaleDownThreshold {
@@ -234,10 +234,19 @@ func (ch *ConcurrencyHandler) MonitorResponseTimeVariability(responseTime time.D
234
234
}
235
235
} else {
236
236
ch .Metrics .ResponseTimeVariability .DebounceScaleDownCount = 0 // Reset counter if conditions are not met
237
- if stdDev <= ch .Metrics .ResponseTimeVariability .StdDevThreshold {
238
- return 1 // Suggest increase concurrency if conditions are favorable
237
+ }
238
+
239
+ // Check if conditions suggest a need to scale up
240
+ if stdDev <= ch .Metrics .ResponseTimeVariability .StdDevThreshold && averageResponseTime <= AcceptableAverageResponseTime {
241
+ ch .Metrics .ResponseTimeVariability .DebounceScaleUpCount ++
242
+ if ch .Metrics .ResponseTimeVariability .DebounceScaleUpCount >= debounceScaleDownThreshold {
243
+ ch .Metrics .ResponseTimeVariability .DebounceScaleUpCount = 0
244
+ return 1 // Suggest increase concurrency
239
245
}
246
+ } else {
247
+ ch .Metrics .ResponseTimeVariability .DebounceScaleUpCount = 0 // Reset counter if conditions are not met
240
248
}
249
+
241
250
return 0 // Default to no change
242
251
}
243
252
You can’t perform that action at this time.
0 commit comments