Skip to content
System Design Lab
Microservice Patterns

Deployment Patterns

Several services per host, one per VM, one per container, or serverless functions: how each packs, isolates and scales services — and why serverless trades idle cost for cold starts.

Beginner 4 min read· Updated 2026-11-18

What you will learn

  • Compare the main ways to deploy service instances.
  • Understand isolation, density and startup time trade-offs.
  • See the cold-start cost of scale-to-zero platforms.
  • Choose a deployment platform for a given workload.

Before you start

Overview

You can keep a car in the garage (always ready, paid for even when parked), rent one for the week, or call a taxi (pay per trip, but you wait for it to arrive). Running software has the same choices.

How service instances are packaged and run decides their isolation, density, start-up time and cost. The main options: multiple services per host (cheap, no isolation), one service per VM (strong isolation, slow to start, coarse), one service per container on a platform such as Kubernetes (good isolation, seconds to start, dense packing — the common default), and serverless functions (no servers to manage, scale to zero, pay per request — with cold starts).

Run it

A webhook endpoint gets three 4-second bursts and silence in between. Compare Instances running (what you pay for) and p99 for always-on containers (A) and serverless functions (B).

Loading simulation…

Comparison

PatternIsolationStart-upIdle costGood for
Several services per hostWeak (shared runtime/OS)FastLowSmall systems, legacy app servers
Service per VMStrongMinutesHighStrict isolation, special OS needs
Service per containerGoodSecondsMedium (min replicas)Most microservices
Serverless functionGood (managed)0.1–2 s cold startNoneSpiky or rare, event-driven work

Reducing cold starts

AWS SAM: a function with SnapStart and a little provisioned concurrency
Resources:
  WebhookFunction:
    Type: AWS::Serverless::Function
    Properties:
      Runtime: java21
      Handler: com.example.Webhook::handle
      MemorySize: 1024
      SnapStart: { ApplyOn: PublishedVersions }        # restore a snapshot instead of booting the JVM
      AutoPublishAlias: live
      ProvisionedConcurrencyConfig: { ProvisionedConcurrentExecutions: 2 }   # two always warm

Trade-offs

BenefitsCosts
CostServerless costs nothing when idle; containers pack densely.Serverless can cost more at sustained high load; VMs waste capacity.
LatencyAlways-on instances answer immediately.Scale-from-zero adds cold starts to the first requests of a burst.
ControlContainers and VMs let you tune runtime, networking and long-running work.Functions limit duration, memory and runtime; platform lock-in grows.

Production considerations

  • Default to containers on a managed platform; use functions for glue, events and spiky jobs.
  • Measure cold starts with your real dependencies (DB connections, SDK init), not a hello-world.
  • Keep a small warm minimum for latency-sensitive paths.
  • Whatever the platform, keep services stateless and configurable from outside.

Further reading

Related topics