Guide as to how many LXCs there can be on a single server

I have a dedicated bare metal server with 4 cores/ 128GB SSD and 8GB RAM that I am thinking of using to host LXCs. Is there a general guide as to how many LXCs I could practically create and how I can limit them to X amount of ram and cpu usage?

You could try lxd.benchmark ?


The first limit would be that of the memory. That is, you can consider that an Ubuntu container when launched, takes up under 200MB RAM.
You can make the calculations for a rough number of containers that fit in 8GB RAM.
When some processes of the containers are not active, they may be pushed to swap, so you could fit a few extra containers.

Personally, I think it gets complicated when you set limits, because you end up suffocating some containers that probably need a bit more memory just for a few seconds.

The most affordable container image is Alpine, so if you can get your services in Alpine, you can fit many more containers.

Assuming that memory is not an issue, the next limit is the number of IP addresses on a bridge. There is a hard-coded limit at 1024, which means that if you work with up to around 900 Alpine containers, you just worry about memory.

Check if you can use shiftfs. Makes thinks better on launching.

As @turtle0x1 said, use lxd-benchmark for your testing. Be conservative at first not to create too many containers because you may crash the server.