Compute
Intermediate 12 min read Compute

Containers on Compute

Containers without the cluster

Managed container services (ECS Fargate, ACI, Cloud Run) run containers without managing servers — a middle ground between worry-free functions and portability-through-needing-a-cluster.

containerFargateContainer InstancesCloud Runorchestration
Prerequisites: Containers on Cloud
Before we start

What you will learn

  • Compare serverless containers vs VMs vs functions
  • Explain ECS/Fargate, ACI, Cloud Run models
  • Choose the right container compute tier
In 60 seconds

Serverless containers remove the node: you define a container (image, CPU, memory), the platform schedules and scales it per request or task. No clusters, no nodes, no patching.

Introduction

What is this?

AWS ECS on Fargate (serverless) or EC2 (you manage nodes); Azure Container Instances (ACI) and Container Apps; GCP Cloud Run (request-driven serverless containers) and Cloud Run services. Container compute sits between VMs (full control, operational burden) and functions (no control, no containers). Scaling is per-container replica driven by requests, events, or schedules.

Motivation

Why do you need it?

  • Packaging via Dockerfiles: reproduce exact runtime, test locally.
  • No node patching or capacity guessing — the platform provides it.
  • Faster cold start than full VMs, more control than functions.
  • Portable image moves between dev, CI, and prod consistently.
Think about it

Mental model

Imagine

Prepacked meal kits delivered fresh on demand

Think of

Serverless containers

The kit (image) is prepared anywhere and delivered (scheduled) as needed — someone else runs the kitchen (the platform), you just order replicas.

Mechanics

How it works

  • You push an image to a registry; the task/revision/service definition lists image, ports, CPU/RAM, env.
  • Fargate provisions the exact resources per task (vCPU/memory) and runs your container in isolation.
  • Cloud Run scales from zero to N replicas based on incoming HTTP; each replica autoconcurrency-controlled.
  • ACI runs single containers and container groups for short-lived or scheduled jobs.
  • Platform handles placement, scaling, health, patching of the runtime — you own only the image.

Comparing compute tiers.

VM
Serverless container
Function
Hands-on

Examples

Run a container without a server

Run a container without a server
# AWS ECS on Fargate
aws ecs create-service --cluster prod --service-name web --task-definition web-task --launch-type FARGATE --desired-count 3 --network-configuration ...
# Azure Container Instances
az container create -n web -g app-rg --image nginx:alpine --cpu 1 --memory 1 --ports 80
# GCP Cloud Run
gcloud run deploy web --image gcr.io/myproj/web:1.4 --region us-central1 --allow-unauthenticated

The image is everything; the platform handles scheduling and lifecycle.

Real world

In production

  • A payments worker runs as Fargate tasks triggered by SQS with per-task memory sized to the job.
  • Cloud Run serves a webhook API scaling to zero in quiet hours.
  • ACI runs scheduled ETL from an Azure container group with health probes.
Guidelines

Best practices

  • Keep images small, immutable, and cross-arch (multi-arch manifests).
  • Set CPU/memory from real profile; Fargate/Cloud Run bill per allocated unit.
  • Prefer per-request concurrency on Cloud Run for efficient cold reuse.
  • Use health checks and min-instances only where latency demands.
Watch out

Common mistakes

  • Choosing serverless containers for long-running stateful databases.
  • Ignoring cold-start: 0% min instances is great for cost, wrong for latency SLAs.
  • Fat images (GBs) starving Fargate start and Cloud Run cold-start times.
  • Port mapping confusion: ECS networking vs Cloud Run generated URLs.
Root cause analysis

Common issues

Error
Container restarts in loop
Root cause

Unhealthy app with failing health check

Fix

Inspect logs; ensure the health-check endpoint responds on the port the platform probes.

Error
Cloud Run cold start exceeds SLA
Root cause

Scaling from zero with large image

Fix

Set min-instances and startup probe, shrink image, or enable warm pools.

When things break

Debugging tips

  • Cold start slow? Debug image size and startup script, not just replica count.
  • OOM on Fargate/ACI? Increase task memory or inspect container logs for limits.
  • Cloud Run scaling noises: check concurrency setting vs max-instances race.
  • Use the platform's built-in tracing (Run traces, ECS log driver) to correlate request→container.
Interviews

Interview checkpoint

Test yourself

Quick quiz

0/1
1

What does 'serverless container' mean operationally?

Go deeper

Official documentation