mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-29 20:11:32 +02:00
avoid graphite drift in active worker count
This commit is contained in:
@@ -11,17 +11,19 @@ module.exports = class RateLimiter
|
||||
|
||||
_adjustLimitUp: () ->
|
||||
@CurrentWorkerLimit += 0.1 # allow target worker limit to increase gradually
|
||||
Metrics.gauge "currentLimit", Math.ceil(@CurrentWorkerLimit)
|
||||
|
||||
_adjustLimitDown: () ->
|
||||
@CurrentWorkerLimit = Math.max @BaseWorkerCount, (@CurrentWorkerLimit * 0.9)
|
||||
logger.log {currentLimit: Math.ceil(@CurrentWorkerLimit)}, "reducing rate limit"
|
||||
Metrics.gauge "currentLimit", Math.ceil(@CurrentWorkerLimit)
|
||||
|
||||
_trackAndRun: (task, callback = () ->) ->
|
||||
@ActiveWorkerCount++
|
||||
Metrics.gauge "processingUpdates", "+1" # increments/decrements gauge with +/- sign
|
||||
Metrics.gauge "processingUpdates", @ActiveWorkerCount
|
||||
task (err) =>
|
||||
@ActiveWorkerCount--
|
||||
Metrics.gauge "processingUpdates", "-1"
|
||||
Metrics.gauge "processingUpdates", @ActiveWorkerCount
|
||||
callback(err)
|
||||
|
||||
run: (task, callback) ->
|
||||
|
||||
Reference in New Issue
Block a user