Skip to content

Bucket4J server side distributed throttling case #277

Discussion options

You must be logged in to vote

Hello @jstgodard

Bucket4j does not support scenarios when multiple buckets can be transitionally updated in single request, where "transactionally" means that if tokens were consumed from one bucket then tokens must consumed from another bucket, and wise versa if tokens were rejected from one then it must be rejected from another.

So there is no way other then solve problem on your side by maintaining many independent buckets and using compensation transactions when tokens were consumed from one but rejected by another:

private Bucket globalBucket = ...;
private Bucket myBucket = ...;

public boolen tryConsume(long tokens) {
   if (!myBucket.tryConsume(tokens)) {
      return false;
   } e…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@jstgodard
Comment options

@vladimir-bukhtoyarov
Comment options

Answer selected by jstgodard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants