>_
EngineeringNotes
Back to DevOps
Concept Architecture

Why ECS & Kubernetes?

Running Docker on a single EC2 instance is simple and works wonders for small projects. But what happens when you scale from one server to dozens, or handle millions of users? That is where container orchestration is born.

The Single EC2 Developer Workflow

For personal portfolios, startups, and small apps, a classic setup is to build a container, push it to a registry, and pull it on an EC2 instance. It looks like this:

Step 1Local Machine
Step 2docker build
Step 3docker push
Step 4EC2 Instance
Step 5Install Docker
Step 6docker pull
Step 7docker run
πŸ’‘ Note: This is completely sufficient for:
  • βœ“ Portfolio & personal projects
  • βœ“ Internal operations & utilities
  • βœ“ Early validation & MVPs
  • βœ“ Small traffic startups

The Breaking Point: High Scale

Suppose your service grows to 1 million users a day. One EC2 instance can no longer handle the payload. You launch multiple servers (EC2-1, EC2-2, EC2-3, etc.). Now, you face these 8 challenges:

1. Scheduling & Placement

The Problem

Where should each container go when you have 5+ EC2 instances and need to launch 10 backends, 5 frontends, and 3 workers? Manually deciding based on CPU/RAM availability is exhausting.

The Orchestrator Solution

Orchestrators monitor cluster resource usage and automatically place containers on the most optimal host instance.

Click to view solution

2. Container Crashes

The Problem

If a container crashes (e.g., due to memory leakage or unhandled exceptions) after running for 2 hours, your service is down until a developer manually logs in to restart it.

The Orchestrator Solution

Orchestrators constantly perform health checks and automatically restart or recreate failed containers within seconds.

Click to view solution

3. Server / Host Crashes

The Problem

If an entire EC2 instance dies, all containers running on it instantly vanish. Your system experiences sudden partial or full downtime.

The Orchestrator Solution

Orchestrators detect host node failures, mark them unhealthy, and reschedule all active containers onto surviving healthy hosts.

Click to view solution

4. Auto-Scaling Limitations

The Problem

If traffic surges 100x overnight, scaling up requires you to SSH into each server, run several 'docker run' commands, and update reverse proxy configs manually.

The Orchestrator Solution

You can scale container instances up or down with a simple config value, or set up autoscalers based on CPU and memory metrics.

Click to view solution

5. Downtime on Updates

The Problem

To deploy v2, you have to stop v1, pull the new image, and run it. This leaves a gap of downtime. If v2 has a critical bug, rollback is a manual restart headache.

The Orchestrator Solution

Orchestrators perform rolling updates, replacing containers one by one to ensure zero downtime, and roll back automatically if health checks fail.

Click to view solution

6. Load Balancing & Discovery

The Problem

When running 10 backend containers across 3 hosts, distributing incoming API requests across them and managing routing endpoints requires complex Nginx configurations.

The Orchestrator Solution

Integrated Service discovery and Load Balancers automatically register new containers and distribute traffic seamlessly.

Click to view solution

7. Desired State Management

The Problem

Ensuring that you consistently have exactly 5 replicas of your API running requires writing custom cron scripts or daemon processes to monitor the host processes.

The Orchestrator Solution

Orchestrators operate on a declarative 'desired state' loop. You define what you want, and the orchestrator works continuously to make it reality.

Click to view solution

8. Configuration Drift

The Problem

Managing DB_URL, API_KEYS, and JWT secrets across multiple instances leads to environment variable configuration drift and security vulnerability leaks.

The Orchestrator Solution

Secure, centralized configuration storage (AWS Systems Manager, Kubernetes ConfigMaps & Secrets) injects variables consistently.

Click to view solution
πŸš€

AWS ECS

Elastic Container Service

ECS is AWS's managed container orchestration service. It is designed to be deeply integrated with AWS ecosystem products (ALB, IAM, CloudWatch, ECR). It is a simpler, opinionated alternative to Kubernetes if your entire stack runs on AWS.

  • 🟒 Managed task scheduling & deployments
  • 🟒 AWS Fargate for serverless container deployment
  • 🟒 Seamless load balancing integration
Explore AWS ECS Module
☸️

Kubernetes

K8s Orchestration

Kubernetes is the industry standard open-source platform. It works across any cloud provider (AWS, Azure, GCP) or bare metal servers. It has a high learning curve but provides complete vendor freedom and advanced automation features.

  • πŸ”΅ True multi-cloud & hybrid environment support
  • πŸ”΅ Giant developer ecosystem & extensive custom plug-ins
  • πŸ”΅ Declarative control loops for self-healing
Explore Kubernetes Module

Feature Matrix Comparison

FeatureDocker on EC2AWS ECSKubernetes
Run Containers Yes Yes Yes
Auto Restart Manual / limited Yes (ECS Agent) Yes (Control Plane)
Auto Scaling No Yes (Task Autoscaling) Yes (HPA / VPA)
Load Balancing Manual setup Yes (ALB integration) Yes (Service / Ingress)
Rolling Updates Manual scripts Yes Yes
Self-Healing No Yes Yes
Multi-Host clustering Difficult Yes (ECS Cluster) Yes (Nodes & Pods)
Learning CurveEasy (Docker Compose)Medium (AWS concepts)High (Complex K8s YAML)

DevOps Learning Path Roadmap

1

Docker and Docker Compose

Learn to containerize applications and run multi-container setups locally. Understand volumes, ports, network links, and image building.

2

Deploy to a Single EC2 Instance

Connect local git/workflows to an EC2 server. Install Docker, do a manual docker pull, and spin it up. This teaches cloud networking and raw host management.

3

Adopt AWS ECS Next

Integrate your containerized stack into AWS container registers (ECR) and run them on ECS clusters (using AWS Fargate serverless engine).

4

Master Kubernetes

Once comfortable with Docker and cloud deployments, learn Kubernetes resources (Pods, Deployments, Services, ConfigMaps, Secrets, Ingress) to manage giant global applications.