19 Eylül 2018 Çarşamba

cgroups - CPU, RAM, Disk Gibi Sistem Kaynaklarını Sınırlama Getirir

Giriş
cgroups control groups anlamına gelir. Açıklaması şöyle.
Systemd creates a cgroup for each user, and all processes of a user belong to the same cgroup.

Cgroups is a Linux mechanism to set limits on system resources like max number of processes, CPU cycles, RAM usage, etc. This is a different, more modern, layer of resource limiting than ulimit (which uses the getrlimit() syscall).

To change the max number of processes systemd will allow for each user, edit /etc/systemd/logind.conf. The default is max 12288 processes per user.
Açıklaması şöyle
We could have created a process separate from the other process with Linux namespaces. But if we create multiple namespaces, then how can we limit the resources of each namespace so that it doesn’t take up the resources of another namespace?

Luckily, in 2007 some people developed cgroups just for us. This is a Linux feature that allows you to limit the resources of a process. Cgroups will determine the limit of CPU and Memory that a process can use. To create cgroup, we will use cgcreate.
cgroup CPU, RAM, Disk gibi sistem kaynaklarını sınırlamaya olanak sağlayan bir kernel özelliğidir. İlk başta Google tarafından 2006/2007 yılında geliştirildikten sonra, 2008 yılında Linux çekirdeğine dahil edilmiştir.

Şeklen şöyle. Burada Docker açısında gösteriliyor ama mantık aynı. Üstte namespaces ile container'ların birbirlerini görmesi engelleniyor. Altta cgroups ile her container için kaynaklara sınırlama getiriliyor.



cgroup-tools Paketi

Kurulum Centos
libcgroup1 paketinin kurulu olması gerekir. Şöyle yaparız
sudo yum install libcgroup
Kurulum  Ubuntu ve Debian
Şöyle yaparız
sudo apt-get install cgroup-tools

cgcreate Komutu - Grup Yaratma
cgcreate komutu yazısına taşıdım

Hiç yorum yok:

Yorum Gönder