Skip to content

Commit 446cb3b

Browse files
committed
f docs
1 parent b1820bf commit 446cb3b

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

lib/api/apiUtils/rateLimit/gcra.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414
* - 600 req/s ÷ 6 nodes = 100 req/s per node → interval = 100ms
1515
*
1616
* Dynamic work-stealing is achieved through Redis sync reconciliation:
17-
* - Each worker evaluates locally at its fixed per-worker quota
18-
* - Workers report consumed / workers to Redis
19-
* - Redis sums all workers' shares
20-
* - Workers overwrite local counters with Redis values
17+
* - Each worker evaluates locally using preallocated tokens
18+
* - Workers report processed requests to Redis
19+
* - Redis sums all workers' requests
2120
* - Idle workers' unused capacity accumulates in Redis
2221
* - Busy workers pull back higher emptyAt values and throttle proportionally
2322
*

lib/api/apiUtils/rateLimit/tokenBucket.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class WorkerTokenBucket {
3535
this.tokens = this.bufferSize; // Start with full buffer for fail-open at startup
3636
this.interval = calculateInterval(this.limitConfig.limit, config.rateLimiting.nodes);
3737
this.lastRefillTime = Date.now();
38+
this.refillCount = 0;
3839
}
3940

4041
hasCapacity() {
@@ -244,7 +245,9 @@ function cleanupTokenBuckets(maxIdleMs = 60000) {
244245
/**
245246
* Remove a specific token bucket (used when rate limit config is deleted)
246247
*
247-
* @param {string} bucketName - Bucket name
248+
* @param {string} resourceClass - "bucket" or "account"
249+
* @param {string} resourceId - bucket name or account canonicalId
250+
* @param {string} measure - measure id e.g. "rps"
248251
* @returns {boolean} True if bucket was found and removed
249252
*/
250253
function removeTokenBucket(resourceClass, resourceId, measure) {

0 commit comments

Comments
 (0)