hbase-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ashish Singhi (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HBASE-13686) Fail to limit rate in RateLimiter
Date Tue, 19 May 2015 13:11:01 GMT

    [ https://issues.apache.org/jira/browse/HBASE-13686?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14550398#comment-14550398
] 

Ashish Singhi commented on HBASE-13686:
---------------------------------------

[~zghaobac], [~mbertozzi] and others can you please review the patch.

Regarding the implementation.
1. I could not find a way to combine the refill logic implemented by AverageIntervalRefillStrategy
and FixedIntervalRefillStrategy so I have added a interface RefillStrategy which defines how
the RateLimiter will refill the resources availability.
2. Added a new configuration property {{hbase.quota.refill.strategy}}, where in user can configure
the refill strategy he/she wants to use. With default being AverageIntervalRefillStrategy.
3. Created a conf object in TimeBasedLimiter, could not a find a better way to pass this object.
If you know any other way then please suggest.
4. With this implementation the timestamps in not in client control, instead will be controlled
by the refill strategy.
5. I have commented the test for Minutes, Hours, Days in TestRateLimiter, as to verify these
test cases will involve high time sleep to refill as timestamps are not in client control.
If you feel the class or methods can be better documented then please suggest, I am happy
to do that.

> Fail to limit rate in RateLimiter
> ---------------------------------
>
>                 Key: HBASE-13686
>                 URL: https://issues.apache.org/jira/browse/HBASE-13686
>             Project: HBase
>          Issue Type: Bug
>    Affects Versions: 2.0.0, 1.1.0
>            Reporter: Guanghao Zhang
>            Assignee: Ashish Singhi
>            Priority: Minor
>             Fix For: 2.0.0, 1.2.0, 1.1.1
>
>         Attachments: HBASE-13686.patch
>
>
> While using the patch in HBASE-11598 , I found that RateLimiter can't to limit the rate
right.
> {code} 
>  /**
>    * given the time interval, are there enough available resources to allow execution?
>    * @param now the current timestamp
>    * @param lastTs the timestamp of the last update
>    * @param amount the number of required resources
>    * @return true if there are enough available resources, otherwise false
>    */
>   public synchronized boolean canExecute(final long now, final long lastTs, final long
amount) {
>     return avail >= amount ? true : refill(now, lastTs) >= amount;
>   }
> {code}
> When avail >= amount, avail can't be refill. But in the next time to call canExecute,
lastTs maybe update. So avail will waste some time to refill. Even we use smaller rate than
the limit, the canExecute will return false. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message