Compute
Compute is the work a CPU or an accelerator does when it executes instructions, and by extension the resource that providers sell and operators share. Every program needs it to turn stored instructions and data into results. How much a processor delivers depends on how fast its clock runs and how much work it finishes in each tick. Two processors with the same clock speed can therefore deliver very different amounts of compute.
Compute never stands alone. Every instruction reads from and writes to memory, so the two are almost always provisioned together. A request for a machine names an amount of each, rather than compute alone. A processor that waits for data does no useful work, so a fast chip with too little memory delivers less than its rating suggests. Providers sell fixed ratios of the two, and a workload that needs an unusual ratio pays for the side it leaves unused.
One layer up, compute is the resource that a workload consumes and that infrastructure divides among many workloads. How it is counted and how it is shared decide what running a program costs and how fast it finishes. Running many small workloads on one large machine spreads its fixed cost. That is why cloud compute is sold in slices far smaller than a server, and why a virtual machine can be cheap enough to create for a single task.
Units of compute
Units of compute are the measures used to count it, and the right one depends on who is counting. Each unit answers a different question, from how long a program ran to how much capacity was held for it. An operating system counts what a process actually used, because it schedules that time and can measure it directly. A provider counts what it reserved, because reserved capacity cannot be sold to anyone else.
Most bills count vCPUs held over time, whether or not they were busy. That unit rewards keeping held processors busy, because a reserved processor that sits idle costs the same as one that works. On many clouds a vCPU is one hardware thread of a physical core, not a whole core. Comparing prices across providers therefore means checking what a vCPU stands for on each.
A workload that waits on the network for most of its life pays for compute it does not use. Short-lived workloads are often billed by the second, or packed many to a machine, for this reason. An agent that spends most of a session waiting for a model to reply is a common case. Per-second billing cuts the waste at the end of a run, but not the idle time within it.
| Unit | Counted by | Description |
|---|---|---|
| Processor time | Operating systems | Processor time is the seconds a process spent running on a core. |
| Operations per second | Benchmarks | Operations per second is the number of operations, such as floating-point operations, that a processor finishes each second. |
| vCPU time | Cloud providers | vCPU time is the number of vCPUs held, multiplied by the hours or seconds they were held. |
General-purpose and accelerated compute
General-purpose and accelerated compute are the two broad kinds of compute, told apart by the chip that supplies them. General-purpose compute runs on CPUs, which handle any program but do a modest amount of work per clock cycle. A CPU core spends much of its chip area on predicting branches and reordering instructions. That design keeps one stream of code fast even when it is full of decisions, as in a web server or a compiler.
Accelerated compute runs on a GPU or another specialized chip. It does far more arithmetic in parallel, but only for problems that split into many identical pieces, such as matrix multiplication in machine learning. A GPU spends its area on many simple cores instead, which run the same instruction on different data at once. Code full of branches runs poorly on it, because cores that take different paths wait for each other.
Most systems use both kinds together. The CPU runs the program and hands the parallel parts to the accelerator, so the speed of the whole depends on how much of the work splits that way. Moving data between the two chips takes time, so a handover pays off only when the parallel part is large. An accelerator is also harder to share between virtual machines, so it is often given whole to one machine or split by the chip itself.
Compute as a shared resource
Compute as a shared resource is processor time divided among many workloads on one server. The kernel and the hypervisor give each workload slices of that time, and limits stop one from taking slices meant for another. Each slice is short, so workloads that take turns on one core all appear to run at once. A limit is usually set as a fraction of a core, and a workload that reaches it waits for the next period.
Most workloads are idle much of the time, so operators often promise more compute than the hardware has. This practice is called overcommit, and it works as long as few workloads are busy at once. When many wake together, each gets a smaller share and runs slower, but none of them fails. That slowdown is what users of a crowded host notice as a noisy neighbor.
Memory is harder to divide this way, because a program cannot run on less of it the way it can run on less processor time. On a busy host, memory usually runs out before processor time does. A workload that cannot get the memory it needs is either swapped to disk, which makes it far slower, or stopped by the kernel. Operators therefore overcommit memory more cautiously than processor time.