Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the typical uses cases for LXC versus VM?

I am trying to make up my mind on when an LXC container can be a better choice than using a full VM.

Do you have any precise uses cases in mind that can bring some arguments in one way or another?

Are LXC more "PaaS" oriented, to run applications without hardware control? Do we always need to use VM on an "IaaS" perspective where we want infrastructure control?

Regards,

like image 655
MorganK Avatar asked Jun 11 '13 12:06

MorganK


3 Answers

LXC is like a chroot jail on steroids. For sake of argument, you can consider it a light weight VM (even though it's not a VM at all).

If you've already gone through the effort of writing an application that is designed to live on ephemeral infrastructure, then LXC just lets you do it with less overhead.

For me, the coolest thing about LXC is the community growing around it. Consider something like docker - a docker image is relatively portable. It provides the tools to configure identical containers on physical hardware, or within a VirtualBox VM running on your desktop, or within VM's provided by Amazon or Rackspace. This brings us closer to the dream of write-once run-anywhere.

like image 149
Vinay Sahni Avatar answered Oct 16 '22 10:10

Vinay Sahni


I don't think IaaS needs VMs. With LXC you can define # of cpushare and Memory user limit.

The thing is VMs are pretty heavy so for example PHP/MySQL/Apache, you would have 1 VM. As LXC are light, you could have 3 LXC, so it much better for scaling, (if you need to shard mysql, just duplicate the mysql LXC)

like image 35
vieux Avatar answered Oct 16 '22 10:10

vieux


LXC's start much faster than VMs and use fewer host resources per container than VMs, so they are ideal for combinations of packing a lot of isolated processes onto one host and/or starting them up frequently.

One use case is for running unit tests in reproducible environments (when combined with a snapshotted file system, as Docker provides). You could spin up a whole container, run the test, and shut it down as fast as you could just run the test. The benefit of the LXC would be that all the non-kernel dependencies of the test would be within the container. It could even be a different flavor of Linux (eg the host could be Ubuntu and the container could run Centos, though they must share the host's kernel).

like image 42
Andy Avatar answered Oct 16 '22 10:10

Andy