Hi,
I am facing the following issue with SmoothWarmingUp RateLimiter.
RateLimiter rateLimiter = RateLimiter.create(3000, 1, TimeUnit.SECONDS);
Stopwatch timer = Stopwatch.createStarted();
int count = 0;
while(!Thread.currentThread().isInterrupted()) {
rateLimiter.acquire();
count++;
if(timer.elapsed(TimeUnit.SECONDS) >= 1) {
// Prints 1500 ~ 2000 on average
System.out.println(LocalDateTime.now() + " => " + count);
count = 0;
timer.reset().start();
}
}
I tried on different machines, and get only 1500 to 2000 permits per second instead of the expected 3000.
(But I get 3000/second when using a SmoothBursty rate limiter)
I suspect that in case of SmoothWarmingUp rate limiter, it tries to do a TimeUnit.NANOSECONDS.sleep(..) for a very small time, and the thread doesn't wake up in time.
Not sure if this is the expected max throughput when using acquire() with SmoothWarmingUp rate limiter.
Appreciate any information on this. Thanks.