LXD understand limits

Hi, so using lxd profile i can limit cpu for containers for 1 lets say, and ram for 1 gb.
Say 8 have 8 cpu cores. And 12 gb ram.
6 containers in total, will each container use free random or random idle cpu? Will each container occupy ram for limit on the fly?
Or how dose cpu limit specifically work in general?

CPU limit when done through limits.cpu results in cpuset pinning.
On container startup, LXD will balance the containers such that each CPU ideally has the same number of containers.

This isn’t based on load though, so you can still get some surprises.

You could instead use limits.cpu.allowance which allows for a percentage based or time slice based approach which will then have the scheduler keep balancing between all cores.

Good info.
What percentage would you advice? Will 100% percentage mean full capacity of all cores? Or is chosing smaller percent ‘10’ for each container good practice?
On intel i7 6700, will it be able to run 20 containers with good performance? I looked the internet for new benchmarkes could not find recent once. I know disk type and ram play a role too.

100% means one core at 100%, so if you want to give 4 cores, you want 400%.

Note that in this way, the quota is only really applied when under load, if no load is present, containers can burst up to the available resources on the system.

1 Like

Just to get it clearly, using ‘limits.cpu.allowance’ should be used in combination with ‘limits.cpu’, or the first without the last?

You could use limits.cpu to lock onto a number of physical CPUs and then the allowance to restrict how much of those can be used, but I’d say the most common case is to just set allowance to 200% to give the equivalent of two full CPUs but spread across all cores.