Virtual compute sizing
What a cloud VM actually provides
A virtual machine (VM) gives you an operating system environment with allocated virtual processors, memory and virtual devices. You install or run your application inside that guest OS. Amazon EC2, Azure Virtual Machines and Google Compute Engine offer this model. The provider operates the underlying infrastructure; you still manage the guest operating system, application updates, access, data and recovery unless a separate managed service takes over those duties.
For a bookstore API that needs its own OS packages and background process, a VM may be appropriate. If the team only wants to deploy a web application and does not need OS control, a managed app platform may reduce operational work. Start with the workload, not the largest machine.
Translate the vocabulary, not the product
AWS calls a configuration an EC2 instance type and uses an Amazon Machine Image (AMI) to launch the instance. Azure uses VM sizes and OS images, including gallery images. Google Cloud uses machine families, series and machine types, together with boot images. These are analogous roles, not identical specifications. The available sizes, image compatibility, storage and network limits must be checked for the target region or zone.
The common categories are general-purpose for mixed work, compute-optimized for sustained processing, memory-optimized for large working sets, storage-optimized for certain I/O-intensive tasks, and accelerator-equipped machines for compatible GPU workloads. Names and categories vary by provider. A vCPU is a virtual processing unit exposed to the guest: it need not represent an entire physical core or deliver the same throughput on two platforms. CPU architecture (x86-64 or Arm64) matters because the OS image, native libraries and binaries must support it.
Size memory and CPU with headroom
Consider a fictional bookstore service measured at 2.4 vCPU-equivalent demand and 5 GiB application memory during a representative peak. The guest OS and agents require another 1 GiB. Our planning rule reserves 25% of provisioned capacity for each dimension. For memory, (5 + 1) / 0.75 = 8 GiB. For CPU, 2.4 / 0.75 = 3.2 vCPUs. The CPU measurement is valid only on the benchmark architecture and workload; treat it as a sizing estimate, not portable performance.
Our synthetic choices are: A: 2 vCPU/8 GiB; B: 4 vCPU/4 GiB; C: 4 vCPU/8 GiB; D: 4 vCPU/16 GiB. A fails CPU, B fails RAM, and C and D pass both. Choose C as the smallest candidate among these fictional shapes, then measure request latency, memory pressure, disk throughput and error rates. The real provider may not offer this exact shape. A different CPU, storage bottleneck or licensing rule can change the decision.
Burstable performance is not sustained capacity
Some small or burstable machines use a CPU-credit mechanism. Below a baseline they accumulate credits; above it they consume credits. When credits are exhausted, the behavior depends on the specific product and configuration: for example some modes throttle toward baseline, while some EC2 configurations can incur surplus-credit charges. Azure B-family uses a CPU-credit model; do not assume every Google Cloud shared-core type uses the same accounting.
In a deliberately simplified model, a VM earns 12 credits per hour and uses 30 credits per hour under steady load. With 36 credits initially, the net drain is 18 per hour and the balance reaches zero after 2 hours. This is not a provider billing calculator; actual units, caps, modes and behavior must be checked. For sustained work, compare a non-burstable candidate and measure sustained performance rather than only testing a short peak.
Storage, I/O and scaling change the answer
The boot disk contains the operating system. Additional durable block disks can store application data; local temporary disks may be lost during host changes, stop or deletion depending on the product. Disk capacity, IOPS (operations per second), throughput and latency are distinct. A 100 GiB disk is not automatically twice as fast as a 50 GiB disk. Check both VM-level and disk-level limits.
Vertical scaling changes a VM size; it may require a restart or release of allocated hardware and compatible capacity might not be available. Horizontal scaling adds instances. A load balancer can distribute requests, but only if the application can safely share or externalize state. With a benchmarked capacity of 80 requests/s per healthy VM at the target latency, 210 requests/s needs ceil(210/80) = 3 healthy VMs. Four deployed VMs could tolerate losing one under the simplified assumption that all others remain healthy and capacity is independent. This is not an availability guarantee: shared dependencies and uneven load also matter.
Build a reproducible sizing worksheet
Use the offline fixture lab-fixtures/offline/chapter-13-virtual-compute.json. Record workload, peak CPU and RAM, OS overhead, reserve fraction, candidate architecture, disk size and I/O, network needs, operating system support, license constraints and cost assumptions. Reject incompatible candidates before comparing price. Check performance with a representative load test before recommending a real shape. No cloud account is needed for this lesson. In a separately authorized lab, use a supported reviewed image, a bounded VM size and lifetime, private management access, explicit cost estimate and teardown plan. Do not select real resources from this worksheet.
Common mistakes
Do not divide a workload by advertised CPU clock alone or assume two vCPUs equal two dedicated physical cores. Do not choose a memory-heavy shape merely because CPU is high. Do not size the guest using average RAM if peak RAM causes failures. A low short-test price is not proof of sustained affordability. Measure CPU, memory, latency and I/O separately; repeat benchmarks after changing architecture or size. Next, learn how a VM can remain billable after the application has stopped.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Virtual compute sizing — knowledge check
Choose the best answer for each offline scenario.
A workload requires 2.4 vCPUs and 6 GiB including OS. With 25% reserved capacity, which synthetic candidate fits both?
Why is an x86-64 image not automatically usable on an Arm64 VM?
A model starts with 36 credits and drains a net 18 per hour. When does it reach zero?
Which evidence best identifies a disk bottleneck?
Three healthy VMs can handle the peak. What minimum deployed count tolerates one VM loss under the stated independent-capacity assumption?