Intermediate · Containers in the cloud · topic 34 of 50 · 25 min
Choosing where to run a container
Explanation
Many ways to run the same image
Once your app is a container image, you have choices. The image does not change; what changes is how much the cloud manages for you, how you pay, and how much control you have. More control usually means more work. The right answer depends on your team and your traffic more than on technology fashion.
| Option | Examples | You manage | Best when |
|---|---|---|---|
| Serverless containers | Cloud Run, Azure Container Apps, ECS on Fargate | The image and a few settings | Small teams, web APIs, spiky or low traffic |
| Managed Kubernetes | EKS, AKS, GKE | Manifests, add-ons, upgrades, often nodes | Many services, platform skills, need for Kubernetes tools |
| Plain VMs | EC2, Azure VMs, Compute Engine | The operating system, Docker, patching, scaling | Special OS needs, licensed software, very simple single servers |
| PaaS | Azure App Service, AWS Elastic Beanstalk | The code or image and app settings | Classic web apps, teams that want a managed platform without Kubernetes |
Serverless containers in more detail
Cloud Run and Azure Container Apps scale on incoming requests and can scale to zero, so a service with no traffic costs little or nothing. The trade-off is a cold start: the first request after a quiet period waits while a container starts. If that delay matters, keep a minimum number of instances warm, which costs some money all the time.
ECS on Fargate is also serverless in the sense that you manage no servers, but a service keeps its desired number of tasks running all the time. It does not wake up on a request the way Cloud Run does. You can scale it with metrics or schedules, including down to zero tasks at night.
gcloud run deploy orders-api --image asia-south1-docker.pkg.dev/shop-prod/apps/orders-api:1.0.0 --region asia-south1 --min-instances=1 --max-instances=20Decision factors
- Team size and skills: Kubernetes needs people who understand networking, upgrades and its many tools. A team of three developers rarely has that time.
- Number of services: two or three services are easy anywhere. Thirty services with shared policies, service-to-service security and custom tooling start to benefit from Kubernetes.
- Traffic pattern: spiky or quiet traffic suits scale to zero. Steady, heavy traffic can be cheaper on reserved nodes.
- Scale to zero: needed for many small internal tools and test environments. Cloud Run and Container Apps do it natively.
- Cost: compare the whole bill, including load balancers, the Kubernetes control plane fee, idle capacity and the people time to run it.
- Portability: a container image runs anywhere. Kubernetes manifests move between clouds; Cloud Run settings do not, but they are small to rewrite.
A Bengaluru startup grows up
A two-person startup in Bengaluru builds a home-services booking app. They have one API and one worker, little traffic at night and spikes on weekends. They choose Cloud Run in asia-south1: no servers, scale to zero overnight, and a monthly bill small enough to sit inside their credits. Deploys are one gcloud command from CI.
Two years later they have 20 engineers and 28 services, need network policies between services, a service mesh for mutual TLS, and background jobs with GPUs for image checks. Two engineers now specialise in the platform. They move to a regional GKE cluster in Autopilot mode, where the image-check jobs simply request GPUs in their pod specs. The same images are deployed with Kubernetes manifests. Simple, low-traffic internal tools stay on Cloud Run, because there is no reason to move them.
Need help?
Stuck on a word or an idea? Search this course, or every course, and jump straight to the explanation or a worked question.
Try:
Watch the lesson
Choosing where to run a container · 1/7
The same container image can run in many places. The question is how much you want the cloud to manage.
Prefer a video by a teacher? Find free videos on “cloud run vs kubernetes vs fargate when to use which” on YouTube ↗
In real life: A government services portal in Lucknow
A state e-governance team in Lucknow runs a certificate application portal. Traffic is near zero at night and jumps at the start of each admission season. The team of four developers has no Kubernetes experience, and the department already uses Microsoft 365 and Azure. They choose Azure Container Apps in Central India: it scales on HTTP traffic, scales down when idle, and needs no cluster management. A legacy reporting tool that needs a specific Windows component stays on an Azure VM. They write down the decision and agree to review it if they grow beyond fifteen services.
Practice (0/3 done)
A two-person team has one web API with almost no traffic at night and wants the lowest bill with no servers to manage. What is the best fit?
Write recommend(req) that returns where to run a workload. req has: needsOsControl (true/false), containerised (true/false), services (a number) and kubernetesSkills (true/false). Apply these rules in order: (1) if needsOsControl, return "virtual-machines"; (2) if the app is not containerised, return "paas"; (3) if services is 10 or more AND the team has Kubernetes skills, return "managed-kubernetes"; (4) otherwise return "serverless-containers".
Write a short decision record (half a page) for one of these: (a) a college fest website that gets heavy traffic for one week a year; (b) a hospital chain with 15 internal services, a 6-person platform team and strict uptime needs. Say which option you choose, which cloud service, and why, and name what would make you change the decision.
Quick quiz
Read more (free)
Related help
Before this, learn
This topic builds on these. If something here feels new, open them first.
Related topics
- Containers, images and registriesContainers in the cloud · same module
- Core Google Cloud servicesGoogle Cloud and comparing the clouds
- AWS vs Azure vs Google Cloud: the service mapGoogle Cloud and comparing the clouds
- Deploying to the cloudBackend Development · Deployment and scaling
- Azure compute and storageMicrosoft Azure essentials
- Serverless with AWS LambdaServerless, monitoring and cost control
Questions people ask about this
Open a question to see the answer and why. The first ones are this topic's own quiz, so try the quiz above before you peek.
Which platform does NOT wake up on an incoming request from zero instances?
Answer: An ECS service on Fargate
An ECS service keeps its desired task count running; it scales on metrics or schedules, not by waking on a request.
What is the main downside of scale to zero for a user-facing API?
Answer: Cold starts: the first request after a quiet period is slower
A new container must start; a minimum instance count avoids this at some cost.
When is managed Kubernetes usually worth its extra complexity?
Answer: For many services, with platform skills and a need for Kubernetes tools
Kubernetes pays off at scale and with the people to run it.
A team moves an app from Cloud Run to GKE. What usually stays the same?
Answer: The container image
The image is portable; the configuration around it changes.
Which is a PaaS option that can run web apps from code or containers without Kubernetes?
Answer: Azure App Service
Azure App Service (and AWS Elastic Beanstalk) are platforms as a service.
What does "managed control plane" mean in EKS, AKS and GKE?Related
Answer: The provider runs, patches and keeps the control plane available; you manage workloads
The provider operates the control plane; your Deployments, Services and usually nodes remain yours.
When would the EC2 launch type make more sense than Fargate?Related
Answer: For a steady, heavy workload that needs GPUs or special instance types
The EC2 launch type gives you control of instance types such as GPUs, and can be cheaper for steady, tightly packed load.
What does "serverless" really mean?Related
Answer: You do not manage the servers; the provider does
Servers still exist. You just never see, size or patch them, and you pay per use.
Which service runs your container, scales with traffic and can scale down to zero?Related
Answer: Cloud Run
Cloud Run is serverless containers with scale to zero.
Pass the quiz (60% or more) or mark this topic as done when you are ready.
Your progress is saved on this device only.
Next steps
- This is the last topic of “Containers in the cloud”. The module exam comes next.
- Module 8 exam: Containers in the cloud · 12 questions · 20 min, without help. 4 topics of this module still to finish first.
- Then the next module, Infrastructure as code. 50 topics left in the course before the final exam.