How to limit usage of RAM for buff/cache at Linux in 9 easy steps.

First i should mention: Playing mindlessly with this could lead to server instability.

In some cases, some applications “eats” unbelievable amount of memory for buffers/cache, what could lead to different negative outcomes.
For example, if server has 48Gb of RAM and some application uses 40Gb of this RAM for buffer/cache, it might be a good idea to limit RAM usage for this application.
It is up to you to decide if it worth to limit application RAM usage.

So, 9 easy steps:
1. Ensure that cgroups are enabled in your Linux system by checking if the cgroup_enable=memory option is present in the kernel command line. Edit the /etc/default/grub file and update the GRUB_CMDLINE_LINUX parameter if required.

2. Install cgroup-tools: 
#yum install cgroup-tools

3. Create a new cgroup directory to control memory usage: 
#mkdir /sys/fs/cgroup/memory/limited_group

4. Set the memory limit for the cgroup directory. 
#echo “1G” | sudo tee /sys/fs/cgroup/memory/limited_group/memory.limit_in_bytes

5. Edit the /etc/cgconfig.conf file. Adding this will set restriction to 1G:
group limited_group {
   memory {
    memory.limit_in_bytes = 1G;
   }
  }

6. Edit the /etc/cgrules.conf file. Assign Application aaaa1 to limited group
  :aaaa1 containment limited_group/

7. Restart service to apply changes 
#service cgconfig restart

8. Verify that the cgroup is created and the “aaaa1” application is limited: 
#cgget -g memory:/limited_group/aaaa1

9. Easy, right?