-
Notifications
You must be signed in to change notification settings - Fork 8
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
[ddcommon] Add token bucket rate limiter implementation #552
Conversation
BenchmarksThis comment was omitted because it was over 65536 characters.Please check the Gitlab Job logs to see its output. |
Hm. A couple notes:
I do already have an implementation of a rate limiter https://github.com/DataDog/libdatadog/blob/d79091ec56a5050f7e0a5053829b5ca5b12a2f71/sidecar/src/shm_limiters.rs That implementation is based on atomics. Do you want to keep your implementation, or should we rather take my limiter implementation and put the |
@bwoebi my original implementation was using I don't care too much about whose implementation is taken, but having a shared token bucket rate limiter implementation in |
Is there a reason you need it to work across processes? For most of the language libraries the sampling rate limiter is per-process. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #552 +/- ##
==========================================
+ Coverage 70.49% 70.58% +0.08%
==========================================
Files 213 214 +1
Lines 28412 28588 +176
==========================================
+ Hits 20030 20179 +149
- Misses 8382 8409 +27
|
@brettlangdon The primary problem is that PHP tends to have many processes in some configurations, with autoscaling the number of processes depending on load, making the sample rate ... unpredictable. |
What is the performance overhead of using a shared memory rate limiter vs an in-process one? I'd expect it to be quite heavy? |
@brettlangdon Why would there be any extra overhead (apart from the initial mmap call during process init)? It's just pointing to some memory. |
Wouldn't we now be creating contention between processes on shared memory updates? |
That's why the implementation is based on atomics, to avoid any lock contention. |
Superseeded by #560. |
What does this PR do?
Add an implementation of a token bucket rate limiter to
ddcommon
.Motivation
Meant as a reference implementation of the rate limiter intended to be used by tracing clients for their sampling implementation.
Additional Notes
Anything else we should know when reviewing?
How to test the change?
Describe here in detail how the change can be validated.