Server vs Virtual Machine: Understanding the Difference


Wait, wait… pause for a second. Close your eyes and think: what comes to mind when you hear the word “server”?

According to Wikipedia, a server is “a computer that provides information to other computers called ‘clients’ on a computer network.” Isn’t that a vaguer definition than what you expected—or even what you had in mind?

Often, when we talk about servers, we’re actually referring to bare metal machines or virtual machines.

If you don’t know the difference or how virtualization works, don’t worry – we will start from basics then dive deep, so buckle up..


There are two types of servers based on how they are provided for use.

1. Bare metal Servers – A dedicated physical machine, its plain Hardware and OS. If you want to buy a server it will be this category. you get an direct access to hardware resources. Take Laptop for an example that is also an Bare metal.

2. Virtual Machine – A Simulated system which runs on a hypervisor — a layer that divides abstracts and shares the resources of physical server into multiple independent virtual servers. Each VM acts like its own isolated system with Its own operating system.

Virtual Machine

This explain the high level difference. The Servers you use from a cloud providers are Virtual Servers; AWS’s EC2, Azure’s VM etc. Why ? because its efficient. Most use cases don’t require the tremendous capacity of Bare metal servers. We can divide the resources and distribute.

But how this works? How virtualization is achieved? Why some provider give poor performance than others despite having same specs? lets understand step by step.


Starting with Hypervisor

Hypervisor

Hypervisor software is used to create run and manage multiple Virtual Machines on top of the Physical Machine. It is installed on a Physical Machine and acts as a central management tool to share and allocate resources among multiple VMs running on the same physical host..

There are 2 types of hypervisor –
Difference-between-type-1-and-type-2-hypervisors


Resource Virtualization (Distribution)

Hypervisor’s job is to slice physical resources into virtual chunks and assign them to VMs. But here is the thing this allocation is logical, Not always 1:1. That’s where Virtual CPU, Memory ballooning, overprovisioning comes.
And this affects the performance of your VMs. Which is why performance vary with every Cloud Provider despite having same Specs.


What is vCPU (Virtual CPU)?

vCPU don’t exist as a physical entity its just an illusion 🙂

A vCPU is a portion of a physical CPU core allocated to a VM by hypervisor. vCPU isn’t tied to one physical core instead hypervisor schedules vCPUs (tasks) on physical cores like a queue. I wont confuse you more.
This is beautifully explained here – https://virtualizationdojo.com/hyper-v/hyper-v-virtual-cpus-explained/

So, How is it mapped? How can i determine the number of vCPU I have? Take an example; If a server has 2 physical CPUs (single threaded), each with 4 cores
So total logical processors = 2 × 4 = 8 threads
The Hypervisor can work with these available threads to provide vCPU. Does it mean i have 8 vCPU? NOOO!!

Overprovisioning / Oversubscription

In simple terms it is declaring more vCPU than actual threads available. It can be achieved by hypervisor scheduling vCPUs to run tasks on physicals ones by giving vCPU a time-slice to run their tasks. i know it can be difficult to visualize.

So In above example hypervisor can create an illusion of having 16 or 32 vCPU although it has 8 threads to work with. That’s the trick isn’t it? Cloud providers can promise you number vCPU, but does it mean that they provide that many processors?

Proper resourcing can be efficient but sometimes people get greedy that’s when problems start to occur. Performance degradation, VM crashing etc.


Memory Allocation

Can be allocated statically or dynamically

Static Allocation: VM gets a reserved memory. very straight forward.
Dynamic (Ballooning): Hypervisor adjusts RAM assigned to a VM.

Basically hypervisors dynamically reclaim unused memory from VMs and reallocate it to other VMs that need more memory. (Same case as Overprovisioning)
Done right -> optimization (unused Resources don’t go wasted).
Done wrong -> Performance issues.


Well we started with server vs VM and we have learned a lot of information. if you want to dive deep here are some ref documents.

https://aws.amazon.com/what-is/virtualization/
https://www.intel.com/content/www/us/en/gaming/resources/hyper-threading.html
https://guides.beeksgroup.com/BKDI002/Virtual-Compute-and-overprovisioning.html

Servers, virtual or real—it’s all about understanding what’s really running behind the scenes.
Sayōnara..



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *