-
-
Notifications
You must be signed in to change notification settings - Fork 324
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
Watcher resync causes memory usage burst #1209
Comments
Yeah, I imagine we would want to advocate for a The alternative of paginating internally in the watcher is also sensible, we could make a fixed number like If we just do NB: |
Even in 1.27 SIE is just an alpha-level feature, which IIRC means that the feature gate is disabled by default.
It depends. We could change the interface to something like: enum StreamingWatcherEvent<K> {
Added(K),
Removed(K),
RestartBegin,
RestartPage(Vec<K>),
RestartDone,
} That would still let us keep a facade that buffers it down to the existing |
See kube-rs#1209, relatively untested prototype and doesn't include any proposed API changes
* Paginate initial watch list See #1209, relatively untested prototype and doesn't include any proposed API changes * Remove managed_fields stripper Users can do this anyway using for_stream * Make page size configurable * initial clippy fixes Signed-off-by: clux <sszynrae@gmail.com> * more unrelated clippy fixes Signed-off-by: clux <sszynrae@gmail.com> * clippy fixes related to this pr Signed-off-by: clux <sszynrae@gmail.com> * align default pagination size with client-go (500) Signed-off-by: clux <sszynrae@gmail.com> * caveat the page example + rename to page_size name matches what it's called upstream + it's shorter Signed-off-by: clux <sszynrae@gmail.com> * add a new mock test system for the runtime Signed-off-by: clux <sszynrae@gmail.com> * remove unnecessary boxing + slight rename Signed-off-by: clux <sszynrae@gmail.com> --------- Signed-off-by: clux <sszynrae@gmail.com> Co-authored-by: Natalie Klestrup Röijezon <nat@nullable.se>
The initial It could still make sense to add a But there are some downsides downstream for doing this (on top of the api change/complexity Nat mentioned)
regardless, avoiding the internal buffering in the future would benefit things not using reflectors. so, in a future world - like 1/2y from now where |
As of 0.86 we have support for both pagination and (There might be smarter improvements on being able to return data to the user faster rather than buffer in watcher until a full list have completed, but such an upgrade would need to consider reflector usage which needs to wait for its atomic store property - so leaving something like that to potential future proposal.) |
I don't think we strictly need this, just a list at the end of which objects to keep/delete. We never guarantee that the reflector is atomic. |
are you suggesting that we could forward events from the initial-lists, and have the store keep track of elements that it got during the initial-list, so that when the initial-list is complete, it could delete the complement itself? we do currently say that |
Yes.
I think this is a point-of-view thing. |
yeah, that makes sense. less double buffering, and better memory profile. 👍 probably needs some care for the store readiness check, and some care to work for both paged and streaming lists, but worth raising a help-wanted issue for (at the very least). |
Would you like to work on this feature?
None
What problem are you trying to solve?
During a resync all the data must be stored twice (both in JSON and k8s-openapi struct forms), which (for larger clusters) causes the controller infrastructure to consume ~twice (for the initial sync, expect ~3x for later syncs since the old state is also still kept around) as much memory as normal.
This is both a problem in itself (since it can cause the controller to hit memory quotas during these bursts), and for long-term memory usage (since many memory allocators, including glibc and jemalloc, never unmap memory once it has been allocated for the process).
Describe the solution you'd like
We can use paginated lists to minimize the overlap window. However, must be controlled by the user as this makes network traffic chattier, which may cause degradations on high-latency networks.
Describe alternatives you've considered
We can also use the new
?watch=true&sendInitialEvents=true
API, which implements our list-then-watch pattern on the server side. I'd imagine that this would be ideal for us in most regards. However, this is still an alpha-level API, and would cause silent failures in older clusters.Documentation, Adoption, Migration Strategy
We can implement chunking transparently in
watcher
, which would let us at least cut down the window of JSON that we need to parse at any given time. An "even better" solution here would be to implement a new watcher API that supports streaming resync. We should then be able to reimplement the current watcher API as a facade on top of that without major regressions compared to the current implementation. However, we would still need to consider whether that new streaming-resync watcher would be meaningfully helpful for Controller/reflector.Target crate for feature
kube-runtime
The text was updated successfully, but these errors were encountered: