Skip to content

feat(lib-store): Support configuring mem cache capacity as percentage of available memory #491

@sambhav-jain-16

Description

@sambhav-jain-16

Is your feature request related to a problem? Please describe.
The origin supports a mem cache for storing blobs. This cache has a configurable max capacity to avoid OOMs. Currently, the max capacity is hardcoded as num of bytes. Considering 1) the origin is containerized and does not share its memory with other containers and 2) the origin does not consume much mem other than the mem cache, we can conclude that an optimal value for the mem cache capacity would be around 80% of the origin's available memory. If all origins are hosted on the same hardware type, we can share a single config amongst them (the hardcoded number of bytes that == 80% of the host's memory). However, if we host origins on different types of hardware, we would need to recalculate that number for each hardware type and change it whenever we change hardware.

Describe the solution you'd like
Support a %-based capacity configuration, instead of a hardcoded number of bytes. The origin would calculate upon start time how much mem it has available and use that.

In addition to the functionality above, this ticket also includes:

  • Emitting a metric for the final calculated capacity upon start time.
  • Changing the base.yaml config with better defaults, as right now due to this issue, we have hardcoded the mem cache to have 1MB of capacity. We cannot increase this value without risking running into OOMs if someone were to run origin on a host with less memory available than the value we set. A default value like 80% would both be safe and efficient at using the resources available.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions