Score:0

Process memory-usage mismatch in a Kubernetes sidecar container

ru flag

I have a sidecar container with the following resources:

resources:
  limits:
    memory: 512Mi
  requests:
    memory: 64Mi

However, when I run top, I see this:

  • envoy & pilot-agent seem to be using ~ 363MB & 61MB respectively
  • used memory at the top is 54.6MB
  • running free -m gives the following; a seemingly uncorrelated answer
$ free -m
              total        used        free      shared  buff/cache   available
Mem:         385307       47140      315018         292       23148      336021
Swap:             0           0           0

top running in a sidecar

What exactly is going on here, and how much memory are those processes consuming?

Score:1
cn flag

That free and top output is showing about 50,000 MiB used, of a host with about 385,000 MiB memory total.

Containers share a kernel, so host metrics will generally show node wide numbers. Even though namespaces only show your processes and files. This is different from a dedicated VM or physical host, where the operating system only exists to support your application.

Per container numbers requires querying the cgroups numbers. See a few ways to do so over on Stack Overflow: Checking kubernetes pod CPU and memory. Many of which require metrics server.

Beware adding up RESident memory of processes and expecting that to be the exact memory use of the system. This does not include shared memory or caches. And the kernel does weird accounting tricks with memory. Your 3 significant digits is the right idea. Although, in the simple case of a small number of processes, using primarily private memory, its a good estimate.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.