Skip to content

Serverless vs Containers vs VMs

Cloud & DevOps6 min read

Compare serverless, containers and virtual machines on control, cost, scaling and effort, with a simple decision process for each workload.

In this article
  1. The three models in plain terms
  2. Compare them on what matters
  3. When virtual machines are the right choice
  4. When containers are the right choice
  5. When serverless is the right choice
  6. A simple decision process
  7. Common mistakes
  8. What to do next

Choose serverless for event-driven or spiky workloads where you want no servers to manage, containers for most modern applications that need portability and steady scaling, and virtual machines when you need full operating system control, legacy compatibility or strong isolation. Most real systems use a mix. The right answer depends on your traffic pattern, your team's skills, how much operational work you can carry, and how tightly your software is tied to a particular environment.

This article explains each model in plain terms, compares them on the points that matter to a business, and gives a short decision process you can apply to a workload before you commit.

The three models in plain terms

Virtual machines (VMs) emulate a whole computer. Each VM has its own operating system, and you decide what runs on it, how it is patched and how it is sized. You get maximum control and the responsibility that goes with it. Almost any software can run on a VM, including older applications nobody wants to rewrite.

Containers package an application and its dependencies and share the host's operating system kernel. They start in seconds, use fewer resources than VMs and behave the same on a laptop and in production. They need something to run them, whether that is a managed container service or an orchestrator. If the terminology is new, read our guide to Docker for business teams first.

Serverless means you supply code or a container image and the cloud provider handles servers, scaling and much of the patching. Functions run in response to events such as an HTTP request, a queue message or a file upload, and you are typically billed for the work done rather than for idle capacity. The name is slightly misleading: servers exist, you just do not manage them.

These are points on a spectrum of control versus convenience. The more the provider manages, the less you configure, and the more you accept the provider's limits.

Compare them on what matters

QuestionVirtual machinesContainersServerless
Operational effortHighest: OS, patching, scaling are yoursMedium: depends on managed or self-run platformLowest: provider handles most of it
Control over environmentFullHigh within the containerLimited by runtime and provider rules
ScalingSlower, often manual or scriptedFast with an orchestrator or managed serviceAutomatic, down to zero in many cases
Cost patternPay for allocated capacityPay for the cluster or service capacityPay per use, which can suit spiky load
Startup timeMinutesSecondsMilliseconds to seconds, with possible cold starts
PortabilityReasonable, heavier to moveHigh across providersLower, tied to provider services
Best fitLegacy apps, special OS needs, strict isolationWeb apps, APIs, microservicesEvent handlers, glue code, irregular traffic

Treat the table as a guide to questions, not a verdict. Real costs depend on your usage, your provider's pricing and the engineering time involved, which is often the largest cost of all.

When virtual machines are the right choice

VMs are not outdated. They are the sensible choice in several situations:

  • Legacy software. An application that expects a specific operating system, installed services or a licence tied to a machine is often cheaper to lift onto a VM than to rework.
  • Special requirements. Custom drivers, unusual networking, particular kernel settings or software that needs full system access.
  • Strong isolation. A hypervisor boundary is a stricter separation than sharing a kernel. Regulated or multi-tenant workloads sometimes call for it.
  • Predictable, steady load. If a system runs at a constant level all day, reserved VM capacity can be straightforward to budget.

The cost of a VM is your time. You patch the operating system, harden it, monitor it and replace it. A sensible patch management routine is not optional for VMs, and the shared responsibility model puts that work on you.

When containers are the right choice

Containers suit most new application development. They give you consistent environments, quick deployments and a clean path from a developer's machine to production. They fit well with automated pipelines such as those in our GitHub Actions guide, and they make it easier to run several services side by side.

Think carefully about the platform you run them on:

  • A managed container service from your cloud provider removes much of the cluster work and is often the best starting point.
  • A full orchestrator such as Kubernetes is powerful but brings real complexity. Read do you really need Kubernetes before adopting it.
  • Containers still need image scanning, updates of base images, secrets handling and resource limits. They are not secure by default.

Containers also help with portability. A well-built container can move between providers with less effort than code written for one provider's proprietary services, although data, networking and surrounding services still create some lock-in.

When serverless is the right choice

Serverless shines for work that is event-driven, bursty or small:

  • Processing an uploaded file, resizing an image or generating a PDF.
  • Reacting to a queue message or a database change.
  • Scheduled jobs that run for a few seconds each day.
  • Lightweight APIs or webhooks with unpredictable traffic.
  • Glue between services, including parts of an API integration.

It is less comfortable for long-running processes, workloads with constant heavy load, applications needing very low and predictable latency, or anything that does not fit the provider's time and memory limits. Cold starts, where a function must start up after being idle, can add delay to the first request. Debugging and local testing also differ from a traditional application, so teams need to plan for observability from the start. Our article on monitoring and the golden signals applies equally here.

Cost needs a clear head. Pay-per-use looks cheap for low traffic and can become expensive at sustained high volume, where a container or VM may cost less. Model your expected usage using the provider's own pricing documentation before deciding. See also where cloud money goes.

A simple decision process

Run each workload through these questions in order:

  1. Can the software run only on a particular OS or on special hardware? If yes, a VM is probably your answer.
  2. Is the work triggered by events and short-lived? If yes, consider serverless first.
  3. Is traffic steady and the application long-running? A container service or VM is likely cheaper and simpler than functions.
  4. Does your team already run containers well? Use that skill. A tool your team knows beats a theoretically better tool they do not.
  5. How much operational work can you carry? Be honest. Fewer managed pieces means more night-time pager risk.
  6. How important is avoiding lock-in? Containers lock you in least. Serverless ties you most closely to a provider.
  7. What are the security and compliance needs? Check data location, isolation and logging requirements, including EU data residency expectations. Confirm current requirements for your sector.

Mixing is normal. A common pattern is containers for the main application, serverless for background tasks, and a VM or managed service for a database or legacy component. If you are weighing providers at the same time, our comparison of AWS and Azure covers the wider decision.

Common mistakes

  • Choosing by fashion. Adopting Kubernetes or functions because others have, not because the workload needs it.
  • Underestimating operations. Containers and serverless move work around, they do not remove it.
  • Ignoring cost modelling. Neither the cheapest-looking option nor the newest one is automatically cheapest.
  • Splitting too early. Breaking a small app into dozens of functions or services creates complexity. Read monolith vs microservices before you do.
  • Forgetting security basics. Each model needs patching, least privilege access and secrets handling. See cloud misconfigurations to fix first.

What to do next

List your workloads and tag each with its traffic pattern, runtime needs and who looks after it. Apply the decision questions above, pick one low-risk workload and try the model that fits, and measure cost and effort for a few weeks. Revisit the choice when load or team skills change, since the right model today may not be right in two years.

If you would like help with this, the CloudWiss team in Dublin can talk it through. Find out more about our cloud and DevOps services.

Share this article

General educational information, not legal or professional advice for your specific situation.

Frequently asked questions

Is serverless always cheaper than containers or VMs?

No. Pay-per-use suits spiky or low traffic, but sustained heavy load can cost more than reserved containers or VMs. Model your own usage with the provider's pricing.

Can I run containers without Kubernetes?

Yes. Managed container services from the major clouds run containers without you operating a cluster. Many teams never need full Kubernetes.

What is a cold start?

It is the delay when a serverless function starts after being idle. It affects the first request and matters most for latency-sensitive paths. Mitigations vary by provider.

Are virtual machines obsolete?

No. They remain a good fit for legacy software, special operating system needs and strong isolation. They need more patching and management work from you.

Keep reading

Let’s build it

Ready to build with CloudWiss?

Tell us what you want to build, move to the cloud or keep running. We reply with a clear next step.