Review and improve web console's requests to the REST API
Problem to solve
Currently, SG's web console polls info from the REST API every 10sec. Such requests are made for every CRD and the API is built in such a way that the response includes data across every namespace, which causes the response to be quite big depending on the amount of resources that have been created.
Due to the nature of the web console's structure, its homepage lists every single namespace that's being used, along with the amount of CRDs in them. Once a namespace has been selected, the persistent sidebar lists every instance from any of the CRDs on the given namespace, yet the information polled from the REST API includes the data from every namespace, regardless of the namespace that has been chosen.
Also, stats for each cluster are being requested using the same polling frequency, even though it seems such info is only needed on the "Cluster Overview" tab from a specific namespace.
The requests behaviour has been mentioned on #1910, specifically related to the /can-i endpoint, yet no actual decisions has been made in order to improve this.
Proposal
Review and improve the performance of the REST API requests made by the web console. Some suggestions:
- Make sure requests are made exclusively when needed
- Define new endpoints that could handle per-namespace requests
- Define new endpoints that only return the info needed on the sidebar
- Define "lighter" endpoints to check if a given CRD/endpoint info has changed since the last request
- Allow users to specify the frequency rate in which the request will be made (this could be set during the install-phase and adjusted per-session on the web browser)\
- Set different frequency rates for each request set (ie.
can-irequests rate doesn't need to be the same as CRDs'. Also,SGBackupsandSGDbOpsnames don't need to be listed on the sidebar)