-
Notifications
You must be signed in to change notification settings - Fork 275
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
Support QPS throttling in NettyPerfClient #1220
Conversation
Added some dynamic throttling logic in NettyPerfClient to issue POST requests at given QPS.
requestCount.get(), hostSleepTime); | ||
if (targetQPS > 0 && requestCount.get() > 0) { | ||
long val = requestCount.get() * 100 * hostSleepTime / targetQPS; | ||
hostSleepTime = val / 100 + (val > 100 && (val % 100 >= 50 || hostSleepTime == 1) ? 1 : 0); |
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.
I don't really understand your calculation here, can you elaborate?
BTW, I think some simple function like
long rtt = 1000 / request.get() - hostSleepTime;
hostSleepTime -= rrt
might just do
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.
fixed
reset(); | ||
perfClientMetrics.requestRate.mark(); | ||
try { | ||
Thread.sleep(hostToSleepTime.get(hostname)); |
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.
nit: Since this function will be called within a nonblocking function, maybe we shouldn't do a thread.sleep here.
Some think like
Channel channel = ctx.Channel();
ctx.channel().eventLoop().schedule(new Runnable() {
// send the request out.
}, hostToSleepTime.get(hostname), TimeUnit.MILLSECOND);
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.
Thanks for letting me know this. Temporarily use current version, will take your suggestion in future PR after several tests.
Codecov Report
@@ Coverage Diff @@
## master #1220 +/- ##
============================================
- Coverage 69.61% 69.49% -0.12%
+ Complexity 5510 5503 -7
============================================
Files 432 432
Lines 33744 33790 +46
Branches 4290 4298 +8
============================================
- Hits 23492 23484 -8
- Misses 9078 9124 +46
- Partials 1174 1182 +8
Continue to review full report at Codecov.
|
Added some dynamic throttling logic in NettyPerfClient to issue POST
requests at given QPS.