-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FEAT: Producer side rate limiting #163
base: master
Are you sure you want to change the base?
Conversation
I think code can be placed more appropriately different modules. I am hoping for the RL module to be independent. If not completely, then atleast core RL. Can it be done? |
server/src/main/java/com/flipkart/varadhi/web/v1/produce/ProduceHandlers.java
Outdated
Show resolved
Hide resolved
server/src/main/java/com/flipkart/varadhi/utils/weights/ConstantWeightFunction.java
Outdated
Show resolved
Hide resolved
package com.flipkart.varadhi.utils.weights; | ||
|
||
public interface WeightFunction { | ||
float applyWeight(long time, long currentTime, long windowSize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this specific interface.
add the documentation.
server/src/main/java/com/flipkart/varadhi/web/v1/produce/ProduceHandlers.java
Outdated
Show resolved
Hide resolved
server/src/main/java/com/flipkart/varadhi/qos/TopicRateLimiter.java
Outdated
Show resolved
Hide resolved
server/src/main/java/com/flipkart/varadhi/qos/TopicRateLimiter.java
Outdated
Show resolved
Hide resolved
if(suppressionFactor == 0) { | ||
return true; | ||
} | ||
return currentObserved.get() <= lastObserved.get()*(1-suppressionFactor); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this formula?
i would have expected isAllowed = !(random.nextDouble(0, 1) < spuppressionFactor)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current formula will block everything once your condition becomes true. I am also not sure why lastObserved data point is being used here!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need to mention on the class about the thread safety requirements. Right now the code is not correct, functionaly. There are bugs, both logic and concurrency related bugs.
if(suppressionFactor == 0) { | ||
return true; | ||
} | ||
return currentObserved.get() <= lastObserved.get()*(1-suppressionFactor); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current formula will block everything once your condition becomes true. I am also not sure why lastObserved data point is being used here!
server/src/main/java/com/flipkart/varadhi/qos/TopicRateLimiter.java
Outdated
Show resolved
Hide resolved
server/src/main/java/com/flipkart/varadhi/qos/entity/SuppressionFactor.java
Outdated
Show resolved
Hide resolved
server/src/main/java/com/flipkart/varadhi/qos/entity/SuppressionData.java
Outdated
Show resolved
Hide resolved
server/src/main/java/com/flipkart/varadhi/qos/entity/TrafficData.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
public void sendUsageToController() { | ||
scheduledExecutorService.scheduleAtFixedRate(() -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
double check the interplay between "scheduleAtFixedRate" and the delay in getting the suppression data.
server/src/main/java/com/flipkart/varadhi/verticles/webserver/TrafficAggregator.java
Outdated
Show resolved
Hide resolved
server/src/main/java/com/flipkart/varadhi/verticles/webserver/TrafficAggregator.java
Outdated
Show resolved
Hide resolved
server/src/main/java/com/flipkart/varadhi/verticles/webserver/TrafficAggregator.java
Outdated
Show resolved
Hide resolved
server/src/main/java/com/flipkart/varadhi/verticles/webserver/TrafficAggregator.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO:
- Move RL service out of server module.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #163 +/- ##
============================================
+ Coverage 63.11% 70.74% +7.62%
- Complexity 543 1171 +628
============================================
Files 133 217 +84
Lines 2790 5425 +2635
Branches 168 330 +162
============================================
+ Hits 1761 3838 +2077
- Misses 964 1430 +466
- Partials 65 157 +92 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
* DistributedRateLimiter interface that takes in loadInfo from all the clients and returns the SuppressionData for each | ||
* topic so that FactorRateLimiter can use it to limit the traffic. | ||
*/ | ||
public interface DistributedRateLimiter extends RateLimiter<SuppressionData, ClientLoadInfo> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup this works :)
ratelimiter/src/main/java/com/flipkart/varadhi/qos/RateLimiter.java
Outdated
Show resolved
Hide resolved
ratelimiter/src/main/java/com/flipkart/varadhi/qos/RateLimiter.java
Outdated
Show resolved
Hide resolved
|
||
@Slf4j | ||
public class ClientHistory { | ||
Map<String, Deque<TopicLoadInfo>> clientHistoryMap; // clientId to history records |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cant we use array / arraylist instead of dequeu?
ratelimiter/src/main/java/com/flipkart/varadhi/qos/entity/ClientHistory.java
Outdated
Show resolved
Hide resolved
ratelimiter/src/main/java/com/flipkart/varadhi/qos/entity/ClientLoadInfo.java
Outdated
Show resolved
Hide resolved
ratelimiter/src/main/java/com/flipkart/varadhi/qos/entity/LoadPrediction.java
Outdated
Show resolved
Hide resolved
ratelimiter/src/main/java/com/flipkart/varadhi/qos/entity/TopicLoadInfo.java
Outdated
Show resolved
Hide resolved
ratelimiter/src/main/java/com/flipkart/varadhi/qos/entity/TopicLoadInfo.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some more minor comments
This reverts commit 3668174.
No description provided.