rate limiter not working as I'd expect

491 views
Skip to first unread message

Don Gately

unread,
Dec 12, 2014, 4:59:41 PM12/12/14
to guava-...@googlegroups.com
Hi Folks,
I'm doing some testing w/ Guava's rate-limiter, using it in it's warm-up rate-limiter configuration.  I'd expect it to ramp up from 0 to the max-allowed-rate over the specified time.

The problems I see are captured in the embedded image:

In the 1st portion (start to 15:55), I request 4 minutes of warm-up, w/ a max-rate of 350 permits/second.

Problems:

  • the warm-up appears to take more like 10 minutes.
  • the final rate is a fair bit less than 350 permits / second
In the 2nd portion of the graph (15:55 to end), I again ask for 4 minutes of warm-up, and a max rate of 700.

Problems:
  • the warm-up doesn't appear to work at all
  • the final rate is much less than the requested 700 / second
On both occasions, I had ~1K / second requests hitting the rate limiter.  Am I grossly misunderstanding how to use this rate limiter?  (The coder did a great job commenting the code, w/ examples even, but unfortunately, I cannot follow some of the concepts.)

Thanks,
BIM

Chris Povirk

unread,
Dec 15, 2014, 4:40:41 PM12/15/14
to Don Gately, guava-discuss
My suspicion is that you are pointing a large enough number of threads at the RateLimiter. The resulting contention for the lock is what's slowing you down, even though RateLimiter would grant the desired number of permits. Then, because the RateLimiter isn't being fully used, it doesn't warm up as fast as expected.

If that's the case, you could try testing with a single thread and see if you get the behavior you expect.
Reply all
Reply to author
Forward
0 new messages