Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
BAAS-28597: Add counter for limiter wait calls #117
BAAS-28597: Add counter for limiter wait calls #117
Changes from 1 commit
0ae652c
ea92633
9824c33
5edfab1
c0dc87a
9796a86
d861907
e07d007
c4ada0f
8b8c99f
5f81ce0
760c1e6
43a5dab
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
@arahmanan the baas counterpart will be to log the LimiterWaitCount when the function execution finishes similar to how we log
Ticks()
. (This could also be a prometheus counter potentially, or perhaps I can piggyback on the Ticks log and include limiterWaitCount... we can discuss in the BAAS pr though)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.
oh I like the idea of adding it to the ticks log! If we do that, adding a new prom metric won't be necessary.
Check failure on line 506 in runtime.go
GitHub Actions / test (1.16.x, ubuntu-latest, 386)
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.
we aren't actually waiting every time we call WaitN. To be able to determine if we are actually waiting take a look at this as an example. We'll only wait if the delay is > 0.
[opt] in addition to the number of times we waited, I think it would also be valuable to track the total delay for the entire execution.
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.
Oh I see the distinction, does that come down to timing?
We have a rate limit of 10_000_000 and a burst value of 250_000 which I think is effectively 50_000 when you account for the burst divisor,
Aside from a lot of process yielding, I'm not sure I fully understand what scenario we actually wait and for how long.
If we use 10_000_000 ticks in half a second would we wait another half a second because that is the amount left until we can execute 50_000 ticks (provided by fillBucket)?
If we use 10_000_000 ticks with only 1ms left in the "second" window, would we only wait that 1ms before we can execute 50_000 ticks?
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.
If the above is true I assume we could do something like:
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.
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.
From the comment above
WaitN
:In other words, we aren't going to wait if the limit allows those n events to be processed. To be able to determine if we're actually waiting or not, you want to do something along these lines:
Not exactly. We would approximately wait until enough time has passed to process the next 50k ticks. i.e. (50_000 / 10_000_000) => 0.005s => 5ms. You can find more about that here.
This can't happen. The rate limiter won't process more than 10_000_000 ticks / s. So it would just take 1s to process the first 10MM ticks. In other words, since we process 50k ticks at a time, a function can process at most 50k ticks every 5ms.
These docs do a decent job at explaining how this works. Let me know if you have more questions about it. I'm happy to also hop on a quick call.