Trying to understand LXC RAM and SWAP allocation

Sandbo

Active Member
Jul 4, 2019
84
10
28
34
I have a workstation with 256 GB RAM, and by default the host has only 8 GB SWAP.
With the two LXCs I have, as they can potentially use a lot of RAM, I committed 192 GB RAM and 64 GB SWAP to both.

My question is, in a situation where both LXC reaches a high usage and they consume more than 256 GB in total, are they able to use their individual space for accessing the 64 GB SWAP?
I read somewhere that the way it works is, the LXC's SWAP can only sum up to the host (which is 8 GB here). To make it really works, should I increase the host SWAP size first?
 
As I understand it: at the moment the maximum swap of a LXC is equal to the memory setting plus the swap setting. In your case: 192GB + 64GB = 256GB of swap allowed by each container and it also has a maximum of 192GB of actual memory.
And yes, all containers together are limited to the size of the actual host swap space. In your case (because of the reason above): the containers require 512GB of host swap space on disk but are limited to the actual 8GB available (that is 8GB together, not necessarily 4GB each), minus any swap used by the host ofcourse.
 
  • Like
Reactions: Dunuin
As I understand it: at the moment the maximum swap of a LXC is equal to the memory setting plus the swap setting. In your case: 192GB + 64GB = 256GB of swap allowed by each container and it also has a maximum of 192GB of actual memory.
And yes, all containers together are limited to the size of the actual host swap space. In your case (because of the reason above): the containers require 512GB of host swap space on disk but are limited to the actual 8GB available (that is 8GB together, not necessarily 4GB each), minus any swap used by the host ofcourse.
Thanks a lot, I think I am clear about how it allocates now.
In this case, I will probably get a dedicated SSD for doing the SWAP in case we hit a high usage scenario.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!