Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have asked this question on SO, but was suggested that i ask it here on SF, so here it goes.

http://stackoverflow.com/questions/3010753/wastage-of-resources-in-virtualization

I am not sure if this is the right place to ask the question. However i hope it is.

When looking for a VPS earlier today, I was trying to understand how each container would work in the background. Keeping in mind the fact that the operating system uses most of the memory and power on a system, wouldn't having multiple operating systems in the same machine mean more wastage of resources.

For instance if i was running centOS on a dedicated box and it was running lets say 20 background OS level processes. Then i go and install a virtualization platform and install 5 more centOS virtual machines in the same system which are exactly the same as the host operating system. Doesn't this mean duplication of those 20 processes 6 times? So internally the context switching is happening between 120 processes instead of 20?

Further Notes: Here is an example of what i am thinking: I have a master-slave configuration for a long running, cpu + memory intensive process, which can be distributed to 4 machines. Lets say when the process runs on these 4 machines with lets say 1 Gh CPU and 1 Gig RAM, i get 400 results per hour from the cluster (assuming 100 results from one machine) . Now i get a bigger machine ( lets say 4Gh and 4 Gig RAM), have 4 virtual hosts on it with 1 Gz CPU and 1 Gig RAM. Will this configuration give me the same 100 results per hour from these 4 virtual hosts?

share|improve this question
add comment

3 Answers

up vote 2 down vote accepted

Most processes in the guest machines will be in sleep state almost the whole time. You can check how much processes sleep with the ps command. On modern hypervisors, duplicate memory pages are shared between virtual machines with a technique called KSM on Linux. VMware has the same thing. Not sure about Hyper-V these days.

All in all, virtualization has overhead, but not as much as you think.

share|improve this answer
    
that is excellent, so shared paging results in lesser use of memory i presume? However as "Chopper3" pointed this may mean a security compromise? –  Sabeen Malik Jun 11 '10 at 8:16
    
no, page sharing isn't a security issue as it only shares identical pages, if one changes it isn't shared - wzzrd's right, it's been in VMWare for years and makes a huge difference. –  Chopper3 Jun 11 '10 at 8:21
    
Sabeen, I think you misunderstand Chopper3's comment. Sharing memory pages is something that goes on on the server side using CoW techniques. A virtual machine does not 'know' it is using shared memory pages. Also, Host - Guest communication is possible - to some extent - already in VMware and probably will be in future versions of KVM as well. This communication will be limited though. Mostly information polling from host to guest. Not guest to host, not guest to guest. On VMware, there's a bit more. Google for HGFS. I'm out of characters :-) –  wzzrd Jun 11 '10 at 8:21
    
OK so seems like this has been on the table for a while , cant the host to guest, guest to guest and guest to host communication be an optional feature which the owner can turn on based on the fact what he is trying to do or is that something which would they deem as a complete waste of time? Also can you guys tell me if there is an actual parallel processing happening in multi-core computers, cause from what i have read it says its dependent on the OS. So a VM with a traditional OS would be "off" for sure for a certain time while waiting for its turn on the host. –  Sabeen Malik Jun 11 '10 at 8:29
    
VM Guests get scheduled by the hypervisors so they are "off" or more accurately not actively scheduled for a lot of the time depending on load. If the Guest is not actively seeking CPU resources the VM will typically not actually get cycles. The time slicing is relatively fine but it does make things like timing using clock ticks troublesome in VM Guests. The Hypervisors deliver true parallel scheduling if you have multiple cores - on a dual CPU Opteron 6100 system there could be 24 VM Guests actively processing instructions at exactly the same time. –  Helvick Jun 11 '10 at 9:27
show 1 more comment

Firstly, "the fact that the operating system uses most of the memory and power on a system", that's far from a fact, very far for most servers actually.

But to answer your question yes it does mean all those processes are going on, but the idea is that with today's multi-core CPUs a single OS can hardly every use all available resource, so why not use it to virtualise. If you have a single old CPU then sure it'll slow everything down but that's not what happens in the majority of cases.

share|improve this answer
    
what i meant by that statement was simply the fact that OS uses alot of resources to manage everything and at any given time there are several processes running in the background which are specific to the OS. Also from the question what i am try understand is as operating systems today on time-share basis, most operating systems on one system mean more context switching and eventually mean more time wasted. Assuming that given the specs of 2 Ghz + 2 Gig RAM, a virtual machine vs normal machine , would they perform equally? –  Sabeen Malik Jun 11 '10 at 7:54
    
what's much more of a waste of time is not using the hardware at all - that's why virtualisation is the hot button topic right now - we have more cycles than we can use most of the time. Oh and you usually lose around 5%-15% performance depending on application. –  Chopper3 Jun 11 '10 at 8:01
    
There's a performance impact of virtualization, of course, and you have to weigh it against the pros of virtualization every time. Some stuff isn't going to be well-suited for virtualization but it gets better each year as the hardware-features in cpus, nics and so on for virtualization increases in features. The impact varies depending on what you're running and can in many circumstances be close to zero - but in others be quite large... –  Oskar Duveborn Jun 11 '10 at 8:03
    
OK thank you, that is just what i thought. So is there any research work or experimental stuff going on which would put the common processes between multiple vhosts into one poll and treat them as one process or is that a complete no-no. From what i understand, virtualization would really become awesome if there could be possible inter-communication between the hosts and instead of duplicating background processes they work together in one shared poll, wouldtn't something of this sort give a great deal of boost to performance? –  Sabeen Malik Jun 11 '10 at 8:06
    
Undoubtably not, one of the benefits of virtualisation is the very specific boundaries between VMs, giving us extra security etc - taking this benefit away would be pretty stupid for the sake of a few clock cycles. I think you're overestimating the cost of the various background processes, most OSs only use a few % of a single core to do these and in a world of 256 thread servers it's a tiny, tiny issue that few would be interested in. –  Chopper3 Jun 11 '10 at 8:11
show 1 more comment

I see the part of your question pertaining to OS footprint was already answered back at SO, so I'll only go into the performance considerations here.

You will not get the exact same level of performance. However, I can't tell you with certainty if the performance is going to be better or worse.

  • Yes, even with the today's state-of-the-art hardware and hardware assisted virtualization, there is still a certain amount of overhead incurred. However, this overhead is getting smaller by the day and may already be negligible for a given use.

  • On the other hand, following your example of four machines running a distributed process, there are many more variables that might affect performance. For example, it might be that the four nodes need to communicate heavily with each other about what they're doing. In that case, you might see the speed and response time of those communications rise if the four machines run on one hardware machine (using some kind of inter-VM network communication). And that could increase the performance of the overall process.

  • To give another example, let's assume the process is very network-intensive. If you have four physical machines running the process, they will all have their own network interface card. But if you have four VMs running on one server (assuming the server has only one NIC), the VMs will need to share a single NIC. Given equal bandwidth per NIC in both cases, this would decrease performance.

In short: it basically all depends on the available resources, and how heavily each type of resource is being used.

share|improve this answer
    
Thank you for your answer. However in my example i assumed there was 0 latency on the network layer, making it irrelevant, so that we can purely judge the machine performance. –  Sabeen Malik Jun 11 '10 at 8:53
    
That's all well and good but there is never 0 latency at the network layer and even the best networks are going to be many orders of magnitude slower than the speed of the links between cores\sockets on a large multi-cpu system. Your application may not be affected by this which is fine but it is a very important factor that affects the performance of multiple VM application stacks. –  Helvick Jun 11 '10 at 9:19
    
Yes i know, however in an effort to eradicate irrelevant variables, i just made that assumption :) –  Sabeen Malik Jun 11 '10 at 9:27
    
Network speed isn't the only issue, all network (and memory use, for that matter) interrupts in a virtualized environment have a far greater impact on the system than when running natively. This could be a bottleneck if you have a network intensive application running. 10Gb NICs with Netqueue (or whatever you decide to call it, theres several variants) will greatly improve this. –  HannesFostie Jun 11 '10 at 9:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.