File tree Expand file tree Collapse file tree
lib/api/apiUtils/rateLimit Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 *
Original file line number Diff line number Diff 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 */
250253function removeTokenBucket ( resourceClass , resourceId , measure ) {
You can’t perform that action at this time.
0 commit comments