Skip to main content

Force page reclaim in cgroups when their cache usage is higher than the specified threshold

Linux cgroup-aware out-of-memory (OOM) killer accounts RSS, kmem, and cache when calculating memory usage for a cgroup. A process that is running in a cgroup cannot directly control its cache usage. It is a good practice in Kubernetes to set a memory limit for containers. However, even if your program does not consume more than the limit, OOM killer can still kill your container if the total usage (RSS+cache) is bigger than the limit.

To address this issue, I have created a simple tool called cgroup-memory-manager. You can run it as a separate process on a Kubernetes worker node, or as a DaemonSet in Kubernetes itself. This program periodically scans all the child cgroups of the specified parent cgroup and analyzes their memory consumption. When cgroup cache usage is higher than the specified threshold, it triggers a forced page reclaim for that cgroup, but not more than once in the specified time frame.

Comments

Popular posts from this blog

Rust is #20 in TIOBE Index for June 2020

Rust has been Stack Overflow’s most loved language for four years in a row, indicating that many of those who have had the opportunity to use Rust have fallen in love with it. Finally in June 2020 it is in Top 20 languages accordingly to TIOBE index. https://www.tiobe.com/tiobe-index/rust/

Gradle for DevOps, Part 4 - Dynamic Tasks

In the 4th part, we will learn how to create dynamic tasks in Gradle using project parameters. Also, we will discuss very useful features, such as task name abbreviation and task rules. Finally, we will implement a simple CLI, which is based on Gradle tasks and uses the same principles as Kubernetes CLI (kubectl). https://linchpiner.github.io/gradle-for-devops-4.html

My Posts

Various posts that I wrote as a freelance content developer in 2016-2017. The covered topics include OpenStack, Kubernetes, Ceph, AWS. Auto-Healing Containers in Kubernetes Kubernetes: How to Share Disk Storage Between Containers in a Pod Kubernetes: Updating Applications Declaratively through Deployment Kubernetes: Exposing Pods as a Service How to Manage Pods with Replication Controllers in Kubernetes Should You Go ‘Serverless’? The Pros and Cons Seven AWS Lambda Alternatives How to Build a Secure Tunnel from Your On-Premises Data Center to Amazon Cloud Amazon EC2 Container Service vs. Kubernetes AWS Lambda: Features, Limitations and A Few Practical Examples Running Containers in a Multi-Cloud Environment Container Orchestration with Kubernetes: 12 Key Features OpenStack Rally: Designing Custom Tests OpenStack Ironic: Introducing Bare Metal Provisioning OpenStack: Container Orchestration and Containerized Control Planes ...