Building Production Software

Serverless vs Containers vs Virtual Machines

Where your code runs affects your monthly bill, how you scale and how much operations work the team carries. This guide compares the three main options in plain terms and explains how to choose.

By Rahul D SarkerPublished November 18, 2026Updated November 18, 20265 min read

Part of our Building Production Software series. Start with Production-Grade Software: Engineering Practices That Prevent Technical Debt.

The Short Answer

Should I use serverless, containers or virtual machines?

For most new web applications, containers on a managed platform are the sensible default: predictable, portable and simple to run. Serverless functions suit spiky or event-driven work, such as processing uploads or webhooks, where paying only for use saves money. Virtual machines suit software that needs full control of the operating system or cannot be containerised.

Read the transcript

Where your code runs decides three things. Your monthly bill. How you scale. And how much work your team carries. There are three main options. Virtual machines: a whole server you look after. Containers: your app packaged up, run by a platform. Serverless: code that runs only when called, billed per use. So which should you choose? For most web apps, containers on a managed platform are the sensible default. Serverless suits spiky, occasional jobs, like processing uploads or webhooks. Virtual machines suit software that needs full control of the server. And watch the cost at scale. Serverless is cheap when idle, but steady heavy traffic is often cheaper on containers. Pick the simplest option that fits. You can mix them later. The full guide is free at loomstrat.com.

What Each One Is

The three models
ModelWhat you hand overWhat you manage
Virtual machineA slice of a physical server with its own operating systemOperating system, patches, runtime, application, scaling
ContainerA packaged application with its dependencies, run by a container platformThe container image and its configuration; the platform handles much of the rest
Serverless functionA piece of code run on demand by the providerThe code and its settings; the provider runs and scales it

Containers are usually built with Docker and run on a managed service or on Kubernetes. Serverless functions include AWS Lambda, launched in 2014. Some services blur the line: Google Cloud Run runs containers but scales them to zero like serverless.

How They Compare

Side-by-side comparison
Virtual machinesContainersServerless
BillingPer hour, whether busy or idlePer running instance; some platforms scale to zeroPer request and execution time
ScalingManual or slow automaticFast automatic scalingInstant and automatic, within limits
Cold startsNoneNone unless scaled to zeroPossible delay after idle periods
Run time limitsNoneNoneTime limits per execution
PortabilityModerateHigh; runs on any container platformLow; tied to provider services
Operations workHighestModerateLowest
Local developmentStraightforwardStraightforwardHarder to reproduce exactly

Cost: Where Each Wins

  • Low or spiky traffic: serverless or scale-to-zero containers are cheapest, because idle time costs nothing.
  • Steady, high traffic: always-on containers or VMs are usually cheaper per request than serverless.
  • Hidden costs: serverless designs often depend on other paid services for queues, storage and orchestration. Amazon Prime Video publicly described moving one monitoring tool from a serverless design to a single process and cutting its infrastructure cost by more than 90 per cent; see monolith vs microservices.
  • People cost: the cheapest bill can be the most expensive option if it needs a specialist to run. See cloud hosting costs.

Which to Choose

Matching workload to model
WorkloadUsually best
Standard web app or APIContainers on a managed platform
Background jobs triggered by eventsServerless functions
Webhook receivers and scheduled tasksServerless functions
Long-running processing, video, large batch workContainers or VMs
Legacy software that expects a full serverVirtual machines
Machine learning model hosting with GPUsContainers or VMs with GPUs, or a managed AI service

Many products mix them: the main application in containers, with serverless functions for occasional jobs. Avoid splitting into many small serverless functions too early; it brings the same complexity as microservices.

Do You Need Kubernetes?

Kubernetes is powerful and complex. Most small and medium products do not need to run it themselves. Managed container services give most of the benefits with far less to operate. Consider Kubernetes when you run many services, need fine control over scheduling, or have a platform team to look after it.

Frequently Asked Questions

Is serverless cheaper?

For low or irregular traffic, usually. For steady high traffic, containers or virtual machines are often cheaper per request.

What is a cold start?

A delay when a serverless function, or a container scaled to zero, runs after being idle, while the provider starts it up.

Are containers the same as virtual machines?

No. A VM includes a whole operating system. Containers share the host’s operating system kernel, so they are lighter and start faster.

Can I move from serverless to containers later?

Yes, but code that relies heavily on provider-specific services takes more work to move. Keeping business logic separate from those services helps.

Which is most secure?

All can be secure. Serverless leaves more patching to the provider; VMs leave the most to you.

Have a build brief already forming in your head?

Loomstrat Studio scopes, builds, and hands over production software in 3–6 weeks - fixed price, 100% repository ownership.

  • Reply within 24 hours
  • Fixed price before we start
  • Zero technical debt guarantee