[lxc-users] Container scaling - LXD 2.0

Fajar A. Nugraha list at fajar.net
Mon May 9 04:48:40 UTC 2016

On Mon, May 9, 2016 at 7:18 AM, Ronald Kelley <rkelleyrtp at gmail.com> wrote:
> Greetings all,
> I am trying to get some data points on how many containers we can run on a single host if all the containers run the same applications (eg: Wordpress w/nginx, php-fpm, mysql).  We have a number of LXD 2.0 servers running on Ubuntu 16.04 - each server has 5G RAM, 20G Swap, and 4 CPUs.

When you use lxd you can already "overprovision" (as in, the sum of
"limits.memory" on all running containers can be MUCH greater than
total memory you have). See
for example.

I can say that swapping will -- most of the time -- kill performance.
Big time. Often to the point that it'd be hard to even ssh into the
server to "fix" things. Which is why most of my servers are now
swapless. YMMV though.

Do some experiments, monitor your swap activity (e.g. use "vmstat" to
monitor swap in and swap out), and determine whether swap actually
helps you, or cause more harm than good.

Also, what's the story with the 5G RAM? Even my NUCs has 32GB RAM nowadays.

> I have read about Kernel Samepage Memory (KSM), and it seems to be included in the Ubuntu 16.40 kernel.  So, in theory, we can over provision our containers by using KSM.
> Any pointers?

I'd actually suggest "try other methods first". For example:
- you can easily save some memory from php-fpm by using "pm =
ondemand" and a small number in "pm.max_children" (e.g. 2).
- use shared mysql instace when possible. If not, use smaller memory
settings, e.g. http://www.tocker.ca/2014/03/10/configuring-mysql-to-use-minimal-memory.html

This entry from openvz should be relevant if you still want to use KSM
for generic applications running inside a container:


More information about the lxc-users mailing list