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

Unable to configure memcached container resources #9737

Open
NRCan-LGariepy opened this issue Oct 25, 2024 · 2 comments
Open

Unable to configure memcached container resources #9737

NRCan-LGariepy opened this issue Oct 25, 2024 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers helm

Comments

@NRCan-LGariepy
Copy link

Describe the bug

Seemingly impossible to set values in the mimir-distributed chart to set the memory and CPU requests of the various memcached caches that mimir makes use of (chunks, results, etc). No matter the configuration, the caches always use 500m CPU.

To Reproduce

Setting chunks_chache.resources.requests with something like

  resources:
    requests:
      cpu: 100m

I also tried doing the same in memcached.resources.requests to no avail.

Expected behavior

I expected the caches (for example the chunks cache) to use the requests that I provided. Instead, the caches always reserve 500m CPU, no matter what I set.

Environment

  • Infrastructure: RKE2 running on EC2s, managed by Rancher.
  • Deployment tool: Helm
@56quarters
Copy link
Contributor

Yes, this is currently hardcoded to 500m within the Helm chart. Seems reasonable to allow this to be configured if you'd like to attempt a PR.

@56quarters 56quarters added enhancement New feature or request helm labels Oct 25, 2024
@armandgrillet armandgrillet added the good first issue Good for newcomers label Oct 25, 2024
@edwintye
Copy link
Contributor

All the cache is named using - which is quite confusing. The hard coded 500m is in the else part of the statement https://github.com/grafana/mimir/blob/mimir-distributed-5.5.1/operations/helm/charts/mimir-distributed/templates/memcached/_memcached-statefulset.tpl#L92-L102 so you should be able to set the cpu like this (I just use a random number here so it is easier to search in the output).

chunks-cache:
  enabled: true
  resources:
    requests:
      cpu: 321m
      memory: 2480Mi
    limits:
      memory: 2480Mi
index-cache:
  enabled: true
  resources:
    requests:
      cpu: 321m
metadata-cache:
  enabled: true
  resources:
    requests:
      cpu: 321m
results-cache:
  enabled: true
  resources:
    requests:
      cpu: 321m

However, there is a trap here (which we may or may not have fallen into before) and I feel like it deserves a warning. The resources block is rendered as-is which means that memory will not be set if you choose to use override. Obviously there is an "easy fix" in that you can define memory request/limit in your override too BUT the memory allocation via the command line would still be using the allocatedMemory https://github.com/grafana/mimir/blob/mimir-distributed-5.5.1/operations/helm/charts/mimir-distributed/templates/memcached/_memcached-statefulset.tpl#L107 instead of taking the resources (and performing the corresponding calculation). Therefore it is necessary for you to make sure that the memory set via the resources block is compatible with the allocatedMemory value.

The templated out yaml above will yield (for the chunks cache)

      containers:
        - name: memcached
          image: memcached:1.6.31-alpine
          imagePullPolicy: IfNotPresent
          resources:
            limits:
              memory: 2480Mi
            requests:
              cpu: 321m
              memory: 2480Mi
          ports:
            - containerPort: 11211
              name: client
          args:
            - -m 8192
            - --extended=modern,track_sizes
            - -I 1m
            - -c 16384
            - -v
            - -u 11211

which means that oom kill will naturally happen as the cache fills up. An additional condition to calculate a "new allocated memory" if the resource override is used would be very nice and minimize mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers helm
Projects
None yet
Development

No branches or pull requests

4 participants