Skip to content

Independent marketplace for verified cloud accounts

Virtual Machines, Containers and Serverless: Choosing a Compute Model

Three ways to run code in the cloud, with different control, billing and operational burden. This guide compares them on the dimensions that decide real architecture choices.

Virtual Machines, Containers and Serverless: Choosing a Compute Model

Every cloud platform offers more than one way to run your code, and the marketing for each one tends to imply the others are obsolete. They are not. Virtual machines, containers and serverless functions sit at different points on a single trade-off between control and operational burden, and most real systems end up using at least two of them.

This guide compares them on the dimensions that actually decide the question: how you package work, how you get billed, how state behaves, and what you will be doing at two in the morning when something fails. It avoids declaring a winner, because the honest answer depends on things only you know: your traffic shape, your team’s existing skills, and how much of the stack you have a genuine reason to control. Those three inputs decide more than any feature comparison does.

One spectrum, three well known points

The underlying variable is how much of the stack you are responsible for. With a virtual machine you get an operating system and everything above it is yours: packages, runtime, process supervision, patching, log shipping. With containers you hand the machine management to a scheduler and keep responsibility for the image and its contents. With serverless you hand over the runtime too and supply only a function and its configuration.

Each step up removes work and removes control in the same motion. That is the whole trade. The useful question is never which model is best but which parts of the stack you have a reason to control, and whether that reason is still true this year.

Virtual machines, when you want the whole box

A virtual machine is the most predictable of the three. You know what is installed because you installed it. You can run anything the kernel supports, attach whatever storage you like, and reason about performance without a scheduler in the way. For workloads with unusual dependencies, licensed software, kernel modules or long running stateful processes, it is frequently the only sensible option.

It is also the easiest model to cost model, because a machine running all month costs the same every month. That predictability is why so much steady state workload stays on virtual machines even in organisations that have containerised everything else. Providers in the value hosting segment, including Hetzner and Contabo, build their entire offering around this shape.

The cost is maintenance. Patching, hardening, monitoring the host, handling disk fill, replacing a failed instance: all of it is yours. That work does not disappear at small scale, it just gets ignored until it causes an outage. Budget for it honestly when you compare a virtual machine’s monthly price against a managed alternative, because the hours are real even though they never appear on an invoice.

Containers, packaging plus scheduling

Containers solve two problems that are often conflated. The first is packaging: an image bundles your application with its dependencies so that it runs the same way everywhere. The second is scheduling: an orchestrator places containers onto machines, restarts them when they die, and moves them when a host fails.

You can take the first without the second. Running a container on a single virtual machine is a perfectly reasonable deployment strategy and it captures most of the packaging benefit with none of the orchestration complexity. Many teams adopt a full orchestrator too early and spend a year learning it for a workload that would have fitted on two machines.

When you do need scheduling, the benefit is real: bin packing several services onto shared capacity, rolling updates, health based replacement and horizontal scaling without bespoke scripting. Managed control planes remove much of the operational cost, though the worker nodes usually remain yours to patch and pay for. Smaller platforms such as Civo position themselves around a simpler managed cluster experience than the hyperscalers offer.

Serverless, paying for invocations

Serverless functions invert the model. You deploy a unit of code, the platform runs it when an event arrives, and you pay for the execution rather than for reserved capacity. Idle costs nothing. Scaling is the platform’s problem, and it will scale further and faster than you would have provisioned for.

That makes it excellent for spiky, event driven and glue work: responding to an upload, handling a webhook, running a scheduled task, processing a queue. It is less comfortable for sustained high throughput, where the per invocation price eventually exceeds what the equivalent reserved capacity would have cost, and for anything that wants to hold state in memory between requests.

The constraints are specific and worth reading in the provider’s documentation rather than guessing: maximum execution duration, memory ceilings, package size, and concurrency limits that interact with the quota model described in service limits and quotas explained.

How each model bills you

Billing shape is often the deciding factor, and the three models have genuinely different curves.

Model What you pay for Cost when idle
Virtual machine Provisioned capacity by the hour or month Full price
Containers on your own nodes The underlying nodes, plus any managed control plane Full price for the nodes
Serverless Invocations and execution time Close to nothing

The pattern is that virtual machines reward steady load and serverless rewards variable load, with containers landing wherever your node pool policy puts them. Note that none of this includes data transfer, which is billed separately on most platforms and is a common reason a migration saves less than expected. Egress fees explained covers that in detail.

State, cold starts and long running work

Three technical behaviours separate the models more sharply than any feature list. The first is state. Virtual machines keep it naturally, containers keep it only if you attach persistent storage deliberately, and serverless functions should be treated as having none between invocations.

The second is start up latency. A virtual machine is already running. A container starts in a time dominated by image size and whether the image is cached on the node. A serverless function may need to initialise a fresh execution environment, which adds latency to the first request after a quiet period. Whether that matters depends entirely on whether a human is waiting.

The third is duration. Long running processes, background workers and anything holding an open connection for hours fit virtual machines and containers comfortably and fight the serverless model, which is built around short executions.

Operational burden over a year

Compare the models over twelve months rather than over a first deployment, because the first deployment is the least representative moment in a system’s life. Over a year you will patch operating systems, respond to a security advisory, rotate credentials, handle a provider maintenance event, and change the deployment process at least once.

Virtual machines put all of that on you. Containers move the host concerns partly to the platform but add image rebuilding and orchestrator upgrades. Serverless removes most of it but makes you dependent on the platform’s runtime lifecycle, which will deprecate language versions on its own schedule. There is no option with zero maintenance, only different maintenance, and the relevant question is which kind your team is actually equipped to do well.

Mixing models in one system

Most mature systems are mixed, and that is a sign of good judgement rather than indecision. A typical arrangement runs the main application on containers or virtual machines, puts scheduled and event driven glue into functions, and keeps anything with awkward licensing or kernel requirements on a dedicated machine.

The cost of mixing is in the seams: more deployment pipelines, more monitoring targets, more places a credential can live. Keep the number of models deliberate rather than accidental, and make sure each one has a clear reason to exist. The same discipline applies to spreading across providers, which when multi-cloud helps treats honestly.

A decision path that holds up

Ask four questions in order. Does the workload need a specific kernel, licensed software or persistent local state? If yes, use a virtual machine. Is the load spiky, event driven and short lived per unit of work? If yes, start with serverless. Do you run several services that need independent deploys and shared capacity? If yes, containers earn their complexity. Otherwise pick the simplest thing your team already operates confidently.

That last clause matters more than the rest. A familiar model operated well beats an ideal model operated badly, every time. If you are still choosing a platform as well as a model, comparisons such as DigitalOcean against Civo are a reasonable way to see how different providers weight these three options.

Related comparisons

AWS vs IBM Cloud
vs

AWS vs IBM Cloud

IBM Cloud is built around OpenShift, regulated industries and hardware you cannot rent elsewhere. This comparison sets that platform thesis…

Alibaba Cloud vs Tencent Cloud
vs

Alibaba Cloud vs Tencent Cloud

China's two largest cloud platforms grew out of very different parent businesses. Their catalogues overlap, but their strengths, international reach…

Google Cloud vs Hetzner
vs

Google Cloud vs Hetzner

Hetzner sells compute by the unit at a low price. Google Cloud sells a platform. The comparison is really about…

Digital Ocean vs Vultr
vs

Digital Ocean vs Vultr

Vultr gives you more places to run a server and more instance shapes to choose from. DigitalOcean gives you a…

Keep reading

Service Limits and Quotas Explained
Cloud Accounts 7 min read

Service Limits and Quotas Explained

Quotas decide what your account can create before you ever hit a technical ceiling. This guide covers soft and hard limits, where…

Need the account, not just the theory?

Browse documented configurations across every provider in the catalog, or ask us which one fits your workload.

Telegram