Replies: 1 comment 1 reply
-
Hello @fombico About the first question: yes huge request rate on the same key is a problem. There is a solution that is implemented in the scope of the upcoming 7.0.0 release. It is example how to apply this optimization https://github.com/vladimir-bukhtoyarov/bucket4j/blob/7.0/bucket4j-examples/src/test/java/example/distributed/optimizers/batching/HazelcastWithBatchingPerformanceExample.java#L93 About PartitionAware: if I understand correctly it is used for the collocation of logically coupled data on the same node, because state of each bucket is independent this functionality should be neutral for Bucket4j, but of course, it is better to consult with Hazelcast developers, maybe I miss something. And, you can do a quick test, by implementing PartitionAware for your keys and compare behavior with previous. |
Beta Was this translation helpful? Give feedback.
-
Hi there,
I am using Hazelcast
4.0.3
withbucket4j-hazelcast:6.2.0
to implement global rate limits per endpoint.After running load tests, I've noticed two things with my implementation:
For a single global rate limit, the data is stored on the same Hazelcast partition. However, all the operations of a partition are owned by a single Hazelcast operation thread. All the requests would wait on this one thread at some point, leading to performance issues under high load.
Without specifying a partitioning strategy, Hazelcast seems to use
DefaultPartitioningStrategy
by default. When the hashing algorithm incom.hazelcast.internal.serialization.impl.AbstractSerializationService.calculatePartitionHash()
uses the object to determine apartitionHash
, the result will be0
as the object does not implementPartitionAware
. The result is that even if I have rate limits on multiple endpoints, their objects get mapped to the same partition hash of0
, stored in the same partition, and thus would all use the same operation thread.I'm wondering if my understanding is correct, or perhaps I've misconfigured something? Ideally, I would not want all the requests to block on the same thread.
Beta Was this translation helpful? Give feedback.
All reactions