Skip to content
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

[Fleet] Add caching on epr package queries #160130

Closed
juliaElastic opened this issue Jun 21, 2023 · 6 comments
Closed

[Fleet] Add caching on epr package queries #160130

juliaElastic opened this issue Jun 21, 2023 · 6 comments
Assignees
Labels
performance Team:Fleet Team label for Observability Data Collection Fleet team

Comments

@juliaElastic
Copy link
Contributor

Related to #125794

Caching on GET /api/fleet/epm/packages/<name>/<version> API is not implemented, because it fetches info from kibana saved objects, as well as epr.

When hitting the Settings page of an Integration, we are making the query to epr many times (seeing 20+ for one Settings page load). e.g. https://epr.elastic.co/search?package=system&prerelease=true&kibana.version=8.8.2
This is very inefficient and causes unnecessary load on epr.

We could use a library like node-fetch-cache to cache for a ttl of 10m (similarly to other /epm routes cache control headers).

@juliaElastic juliaElastic added performance Team:Fleet Team label for Observability Data Collection Fleet team labels Jun 21, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@juliaElastic
Copy link
Contributor Author

We have changed the archive cache recently, so I'm not sure if this is still an issue.

@nchaulet
Copy link
Member

@juliaElastic I am wondering if can implement some browser caching to avoid those requests use something like Last-Modified or an etag, using a in memory cache server side will increase our memory usage.

I was thinking we could a Last-Modified header like this:

  1. first request Fleet set the Last-Modified header with the installation updated_at value
  2. second request the browser will send the Last-Modified header
  3. in server code we can check this Last-Modified against the installation and have a faster respond without querying the EPR

What do you think?

@juliaElastic
Copy link
Contributor Author

Good idea, we could try first with Etag, as it seems Last-Modified is less accurate.
For integrations not installed, we could have another value used as an Etag.

@nchaulet nchaulet self-assigned this Feb 2, 2024
@nchaulet
Copy link
Member

nchaulet commented Feb 2, 2024

I tried to play with the etag, but it seems a little harder than expected as the /api/fleet/epm/packages/<name>/<version> also fetch the latest available version (that is not very cachable)

It seems we reduced a lot the number of EPR queries needed on the details package for example for the nginx package

Screenshot 2024-02-02 at 2 44 28 PM

@juliaElastic I am wondering if we should just closed that issue

@juliaElastic
Copy link
Contributor Author

Sounds good, I think we can close it.

@nchaulet nchaulet closed this as completed Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Team:Fleet Team label for Observability Data Collection Fleet team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants