What are the typical uses cases for LXC versus VM?

2019-03-27 01:35发布

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,

4条回答
Explosion°爆炸
2楼-- · 2019-03-27 02:10

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.

查看更多
走好不送
3楼-- · 2019-03-27 02:11

To me the advantage of lxc is it help you to have a really small environment. So it use full when you have only one app to run on it. If you want several app running in your environment a VM is better. Another case where a VM is better is when you want use another kernel than the host kernel.

To me lxc is just a really light VM system. With speed and size better. But constraint can not be what you need.

查看更多
【Aperson】
4楼-- · 2019-03-27 02:13

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).

查看更多
冷血范
5楼-- · 2019-03-27 02:18

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)

查看更多
登录 后发表回答