Skip to content

Instantly share code, notes, and snippets.

@kpollich
Last active March 8, 2022 16:26
Show Gist options
  • Save kpollich/19160d0ab0a61e7c4c71704549977429 to your computer and use it in GitHub Desktop.
Save kpollich/19160d0ab0a61e7c4c71704549977429 to your computer and use it in GitHub Desktop.

High-level overview of EPR endpoints

Fleet’s approach to caching package data

  • Fleet utilizes two in-memory caches for caching package data

    • An "archive entry cache" for caching each file included in a package's .zip archive keyed by a filepath: Code
    • A "package info cache" for caching packageInfo objects keyed by a ${name}-${version} string: Code
  • Whenever Fleet calls getPackageFromSource (Code) we will attempt to pull the package archive and package info from their respective caches

  • Caching package archives

    • When Fleet calls getRegistryPackage, we'll attempt to pull the package archive file list from the cache. If it doesn't exist, the full package archive is fetched from EPR, parsed, and cached. Code

Problems with the current approach

  • In-memory caching is inherently unreliable in high-availability Kibana environments with multiple Kibana instances
  • Package data in the cache doesn’t expire, so if a user went through and visited every single package they’d probably crash Kibana by causing it to go out of memory
  • There are inconsistencies between how Fleet does its “parsing” of package archives and how the same logic is implemented in the package registry service to serve endpoints like this.
    • Hopefully band-aid fix in elastic/kibana#126915 is enough to keep things stable here, but this is a point of brittleness for sure
  • Fleet makes inefficient use of package info knowing this cache is primed and available, e.g. image
  • The archive parsing and caching code is generally difficult to reason about, unmaintained, and undocumented

Relevant issues on the backlog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment