NokiaTube | New address | Mode Phone | Off high quality for Nokia Browser
Skip to content

RateLimiter dropping the reqeust even before the Threshold limits #7833

Open

Description

@SunilAntil-CS

Understanding how Rate limter works it we use limiter.tryAcuire() methods

  • Configured Rate: 1000 permits/second → effectively 1 permit every 1 millisecond (ms).

Timeline Example:

  • t = 0 ms: The token bucket is initially empty and starts filling — 1 permit per ms.

  • t ≈ 1 ms: 1 permit is available.

    • Request A calls tryAcquire() → succeeds, consumes 1 permit → bucket is empty.
  • t = 1.2 ms:

    • Request B arrives → fails, since only 0.2 ms has passed and no new permit is available.
  • t = 2 ms: Another permit becomes available.

    • Request C at t = 2.1 ms → succeeds.

This continues as per the configured rate.

Here is the some value of variable during drop

DENIED ] permits=1, nowMicros=2086708445, nextFreeTicketMicros=2086708739, storedPermits=0.000, timeout=0 ?s

Since nowMicros < nextFreeTicketMicros there for below method return zero

private boolean canAcquire(long nowMicros, long timeoutMicros) {
return queryEarliestAvailable(nowMicros) - timeoutMicros <= nowMicros;
}

So this issue might be due to permits deny because number of requests comes more with in milliseconds. i.e sudden brust.

It would be helpful if someone provide any solution without adding any latency in code.

Is similar issue is reported by anyone let us know

Thank you.

Activity

  1. cgdecker commented on Jun 12, 2025

    @cgdecker
    Member

    Are you asking for an option for RateLimiter to support a burst of permits within a time period? There are a number of other issues referring to RateLimiter and burst.

  2. Daksh021 commented on Jul 20, 2025

    @Daksh021

    Hi! I'm interested in contributing to this issue. Is it still open for external contributors? I'd love to work on it if possible.

  3. Daksh021 commented on Jul 20, 2025

    @Daksh021

    Hey, I’ve started exploring this and will submit a PR if it seems like a good fix. Let me know if that’s okay!

  4. Daksh021 commented on Jul 28, 2025

    @Daksh021

    @SunilAntil-CS Hello sir please review my pr and give me necessary guidance and feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions