-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Make single API call to get events and filter them on backend #587
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
Conversation
Current coverage is
|
Can we have one events list request per page refresh? Right now it is O(number or cards). In normal case it takes long time to get all events. I did the timing:
Reviewed 3 of 5 files at r1. src/app/backend/eventscommon.go, line 67 [r1] (raw file): Comments from the review on Reviewable.io |
It's done this way to narrow number of events that we get for filtering to single namespace. I was tempted to do single call but also it may be dangerous for big clusters with many namespaces. Filtering takes O(n + m) where n is number of pods and m is number of events we need to filter. For now we can make single call but keep in mind that for some corner cases it may be actually slower. Review status: 3 of 5 files reviewed at latest revision, 1 unresolved discussion. src/app/backend/eventscommon.go, line 67 [r1] (raw file): Comments from the review on Reviewable.io |
I think this is slower in typical cases (many valid cards) and faster in corner cases (there's a card with many pods). In the case of RC list we get events from all namespaces anyway, so we could get them in one call. Or, how about making one call for each namespace? Instead of a call for each card? Review status: 3 of 5 files reviewed at latest revision, 1 unresolved discussion. Comments from the review on Reviewable.io |
I agree. Ideally we should get events per namespace only once and then use already retrieved data without making API call again. Review status: 3 of 5 files reviewed at latest revision, 1 unresolved discussion. Comments from the review on Reviewable.io |
86f10ec
to
47ba892
Compare
Review status: 2 of 6 files reviewed at latest revision, 2 unresolved discussions. src/app/backend/replicationcontrollerlist.go, line 101 [r2] (raw file): Simple solution that would not need any caching would be to get all events in all namespaces and just filter them. @maciaszczykm @bryk What do you think? Comments from the review on Reviewable.io |
Review status: 2 of 6 files reviewed at latest revision, 2 unresolved discussions. src/app/backend/replicationcontrollerlist.go, line 101 [r2] (raw file): How about you do caching on per-request basis? I.e., you create a cache (e.g., Map) at the start of the request and then pass it to methods that use/fill it. When the request is done, the cache is gone. Other way is to get all events for the list page and from one namespace for details page. Basically two implementations. Does this help? Comments from the review on Reviewable.io |
Review status: 2 of 6 files reviewed at latest revision, 2 unresolved discussions, some commit checks broke. src/app/backend/replicationcontrollerlist.go, line 101 [r2] (raw file): Comments from the review on Reviewable.io |
Review status: 2 of 6 files reviewed at latest revision, 2 unresolved discussions, some commit checks broke. src/app/backend/replicationcontrollerlist.go, line 101 [r2] (raw file): Should we just stick with getting all events for list page and ignore namespaces for now? Comments from the review on Reviewable.io |
Getting all events should be sufficient for most use cases. Now for 1000 pods and 650 events it takes roughly ~500us to filter them.
To not overcomplicate things I'll prepare simpler solution. Review status: 2 of 6 files reviewed at latest revision, 2 unresolved discussions, some commit checks broke. Comments from the review on Reviewable.io |
47ba892
to
1fb4905
Compare
PTAL |
Nice! I see huge speedup. Thanks for fixing this! Reviewed 1 of 4 files at r2, 4 of 5 files at r3. src/app/backend/replicationcontrollerlist.go, line 101 [r2] (raw file): Comments from the review on Reviewable.io |
@maciaszczykm Please also review and if all is OK merge. Review status: all files reviewed at latest revision, 1 unresolved discussion. Comments from the review on Reviewable.io |
1fb4905
to
0d6e5bc
Compare
Review status: 2 of 5 files reviewed at latest revision, 1 unresolved discussion. src/app/backend/replicationcontrollerlist.go, line 101 [r2] (raw file): Comments from the review on Reviewable.io |
Reviewed 3 of 3 files at r4. Comments from the review on Reviewable.io |
Review status: Comments from the review on Reviewable.io |
This is my proposal to solve issue #443 as discussed with @bryk here: floreks@f050cf3
This change will improve performance of both replication controllers list page and replication controller detail page. Now instead of making N api calls to get pod events there is only 1 API call that gets all events in given namespace and then filters events based on given list of pods.
This should be extended to all places where N api calls are made based on some resource i.e. RCs.
This also fixes #402. When last pod on the list didn't have error, card state was shown as pending.
@maciaszczykm @bryk @cheld PTAL
This change is