What are the typical uses cases for LXC versus VM?

故事扮演 提交于 2019-12-04 20:22:02

问题


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,


回答1:


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)




回答2:


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:


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




回答4:


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.



来源:https://stackoverflow.com/questions/17044225/what-are-the-typical-uses-cases-for-lxc-versus-vm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!