A virtual machine (VM) is a program which emulates a computer system. It has a virtual CPU, memory, and storage and appears, from the outside, to be no different than a physical machine with the same hardware.
How Does a Virtual Machine Work?
A virtual machine has an operating system, files, and applications. It works just like a physical computer; it can host websites, run programs, and exist on a network with other systems. If viewed on a screen, the virtual machine appears as a window running within that computers own operating system.
It also has a CPU, memory, and storage, but these are simulated, not physical. Because of this, multiple virtual machines can coexist on one server. When this happens, the server uses a piece of software called a hypervisor to manage them. The hypervisor maps the VM’s virtual hardware to the physical components on the server.
In this scenario, one physical server might have two, three, four, or even ten virtual machines running on it. However, the number is limited by the resources of the server – too many VMs will lead to reduced performance.
Why Are Virtual Machines Used?
Virtual machines are sandboxes – pieces of virtual space in which code can be run separately from the rest of the system. This makes VMs ideal for testing new software or running code that might be malicious.
The virtual machine can run a different or older OS to enable a user to run software that won’t work on the computers operating system. For example, someone might use a VM to run a piece of Windows software on a Linux device. To achieve this, they would run a virtual machine running a Windows operating system on their Linux system.
Key Example: The Ethereum Virtual Machine (EVM)
The nodes on the Ethereum network all run the Ethereum Virtual Machine (EVM), which is used to execute smart contracts. Because this happens in a separate sandbox, it provides considerable security benefits for the Ethereum platform, making it immune from the DDoS (Distributed Denial of Service attacks that are a go-to strategy for many hackers.