2

After some research, I found out that, kubernetes logs -f <pod> reads logs from files, i.e, .log files to which docker containers running inside the pods have written the logs. In my case, docker container is an application that I have written. Now, say I have disabled logging in my application expecting that RAM usage on the system will reduce.

  1. With logging enabled in my application, I kept track of CPU and MEM usage

    Commands used:

    a. top | grep dockerd

    b. top | grep containerd-shim

  2. Without logging enabled also, I kept track of CPU and MEM usage.

But I didn't find any difference. Could anyone explain what is happening here internally?

Rico
  • 58,485
  • 12
  • 111
  • 141
Guna K K
  • 155
  • 2
  • 9

1 Answers1

3

The simple explanation:

  • Logging doesn't use a lot of RAM. As you said, the logs are written to disk as soon as they are processed so they are not stored in memory other than just one time variables used per log entry.
  • Logging doesn't use a lot of CPU cycles. The CPU is typically at least 10 to the -5 orders of magnitude faster than disk (less for SSDs) so your CPU can do a lot more when logs are written to disk. In other words, you'll barely notice the difference when disabling the logs in terms of CPU usage.
Rico
  • 58,485
  • 12
  • 111
  • 141