Other Compute Services
EC2 is not the only way to run code on AWS. This chapter covers the two families the deck groups together: containers (Docker, ECS, Fargate, ECR, EKS) and serverless (Lambda, API Gateway, Batch), plus the simplified all-in-one offering Lightsail.
1. What is Docker?
Section titled “1. What is Docker?”Docker is a software development platform to deploy apps. Apps are packaged in containers that can be run on any OS, and they run the same regardless of where they run:
- Any machine
- No compatibility issues
- Predictable behavior
- Less work
- Easier to maintain and deploy
It works with any language, any OS, any technology, and you can scale containers up and down very quickly (seconds).
Where Docker images are stored
Section titled “Where Docker images are stored”Docker images are stored in Docker Repositories:
- Public: Docker Hub (
hub.docker.com) — where you find base images for many technologies or operating systems: Ubuntu, MySQL, NodeJS, Java… - Private: Amazon ECR (Elastic Container Registry)
Docker versus Virtual Machines
Section titled “Docker versus Virtual Machines”Docker is “sort of” a virtualization technology, but not exactly: resources are shared with the host, so you can run many containers on one server.
| Virtual machines | Docker |
|---|---|
| Infrastructure → Host OS → Hypervisor → each app gets its own Guest OS (VM) | Infrastructure → Host OS (EC2 Instance) → Docker Daemon → many containers side by side |
2. ECS – Elastic Container Service
Section titled “2. ECS – Elastic Container Service”ECS lets you launch Docker containers on AWS.
- You must provision & maintain the infrastructure (the EC2 instances)
- AWS takes care of starting / stopping containers
- Has integrations with the Application Load Balancer
3. Fargate
Section titled “3. Fargate”Fargate also launches Docker containers on AWS, but:
- You do not provision the infrastructure — no EC2 instances to manage, which is simpler
- It is a serverless offering
- AWS just runs containers for you based on the CPU / RAM you need
4. ECR – Elastic Container Registry
Section titled “4. ECR – Elastic Container Registry”ECR is the private Docker Registry on AWS. This is where you store your Docker images so they can be run by ECS or Fargate.
5. Amazon EKS – Elastic Kubernetes Service
Section titled “5. Amazon EKS – Elastic Kubernetes Service”EKS allows you to launch managed Kubernetes clusters on AWS. Kubernetes is an open-source system for the management, deployment, and scaling of containerized apps (Docker).
- Containers can be hosted on EC2 instances or on Fargate (serverless)
- Kubernetes is cloud-agnostic — it can be used in any cloud (Azure, GCP…)
In an EKS cluster, EKS nodes (EC2 instances) host EKS Pods, and new Docker containers are scheduled into those pods.
6. What is serverless?
Section titled “6. What is serverless?”Serverless is a paradigm in which developers don’t have to manage servers anymore — they just deploy code, they just deploy… functions.
Initially, serverless == FaaS (Function as a Service). Serverless was pioneered by AWS Lambda but now also includes anything that’s managed: databases, messaging, storage, etc.
Serverless does not mean there are no servers — it means you just don’t manage / provision / see them.
Services already seen in the course that are serverless: Amazon S3, DynamoDB, Fargate and Lambda.
7. AWS Lambda
Section titled “7. AWS Lambda”Lambda is best understood against EC2:
| Amazon EC2 | AWS Lambda |
|---|---|
| Virtual servers in the cloud | Virtual functions — no servers to manage |
| Limited by RAM and CPU | Limited by time — short executions |
| Continuously running | Run on-demand |
| Scaling means intervention to add / remove servers | Scaling is automated |
Benefits
Section titled “Benefits”- Easy pricing: pay per request and compute time. Free tier of 1,000,000 Lambda requests and 400,000 GB-seconds of compute time
- Integrated with the whole AWS suite of services
- Event-Driven: functions get invoked by AWS when needed
- Integrated with many programming languages
- Easy monitoring through AWS CloudWatch
- Easy to get more resources per function — up to 10 GB of RAM
- Increasing RAM will also improve CPU and network
Language support
Section titled “Language support”- Node.js (JavaScript)
- Python
- Java
- C# (.NET Core) / Powershell
- Ruby
- Custom Runtime API (community supported, for example Rust or Golang)
- Lambda Container Image — the container image must implement the Lambda Runtime API; ECS / Fargate is preferred for running arbitrary Docker images
Pricing example
Section titled “Pricing example”- Pay per call: the first 1,000,000 requests are free, then $0.20 per 1 million requests (
$0.0000002per request). - Pay per duration (in increments of 1 ms): 400,000 GB-seconds of compute time per month for free — that is 400,000 seconds if the function has 1 GB of RAM, or 3,200,000 seconds at 128 MB of RAM. After that, $1.00 for 600,000 GB-seconds.
It is usually very cheap to run AWS Lambda, which is a large part of why it is so popular.
Two classic Lambda patterns
Section titled “Two classic Lambda patterns”Serverless thumbnail creation — a new image pushed into S3 triggers a Lambda function that creates a thumbnail, pushes the new thumbnail back into S3, and writes metadata (image name, image size, creation date…) into DynamoDB.
Serverless CRON job — CloudWatch Events / EventBridge triggers a Lambda function every 1 hour to perform a task, with no server sitting idle between runs.
8. Amazon API Gateway
Section titled “8. Amazon API Gateway”API Gateway is a fully managed service for developers to easily create, publish, maintain, monitor, and secure APIs.
- Serverless and scalable
- Supports RESTful APIs and WebSocket APIs
- Support for security, user authentication, API throttling, API keys, monitoring
The canonical serverless API is Client → API Gateway (REST API) → Lambda (proxy requests) → DynamoDB (CRUD).
9. AWS Batch
Section titled “9. AWS Batch”AWS Batch is fully managed batch processing at any scale.
- Efficiently run 100,000s of computing batch jobs on AWS
- A “batch” job is a job with a start and an end (as opposed to continuous)
- Batch will dynamically launch EC2 instances or Spot Instances
- AWS Batch provisions the right amount of compute / memory
- You submit or schedule batch jobs and AWS Batch does the rest
- Batch jobs are defined as Docker images and run on ECS
- Helpful for cost optimizations and for focusing less on the infrastructure
A simplified flow from the deck: a trigger starts AWS Batch, which runs the job on EC2 or Spot Instances via ECS, reading from Amazon S3 and inserting the processed object back into Amazon S3.
Batch vs Lambda
Section titled “Batch vs Lambda”| Lambda | Batch |
|---|---|
| Time limit | No time limit |
| Limited runtimes | Any runtime as long as it’s packaged as a Docker image |
| Limited temporary disk space | Relies on EBS / instance store for disk space |
| Serverless | Relies on EC2 (can be managed by AWS) |
10. Amazon Lightsail
Section titled “10. Amazon Lightsail”Lightsail offers virtual servers, storage, databases, and networking with low & predictable pricing.
- A simpler alternative to using EC2, RDS, ELB, EBS, Route 53…
- Great for people with little cloud experience
- You can set up notifications and monitoring of your Lightsail resources
- Use cases:
- Simple web applications — templates for LAMP, Nginx, MEAN, Node.js
- Websites — templates for WordPress, Magento, Plesk, Joomla
- Dev / Test environments
- Has high availability but no auto-scaling, and limited AWS integrations
Quick recap
Section titled “Quick recap”| Concept | What to remember for the exam |
|---|---|
| Docker | Container technology to run applications; shares the host kernel, no Guest OS per app |
| Docker registries | Docker Hub (public), Amazon ECR (private) |
| ECS | Run Docker containers on EC2 instances you provision; AWS starts/stops the containers |
| Fargate | Run Docker containers without provisioning infrastructure — serverless |
| ECR | Private Docker image repository for ECS / Fargate |
| EKS | Managed Kubernetes; nodes on EC2 or Fargate; Kubernetes is cloud-agnostic |
| Serverless | You don’t manage / provision / see the servers — Lambda, Fargate, S3, DynamoDB |
| Lambda billing | Time run × RAM provisioned, plus the number of invocations |
| Lambda limits | Invocation time up to 15 minutes; up to 10 GB RAM; more RAM also means more CPU and network |
| Lambda free tier | 1,000,000 requests and 400,000 GB-seconds per month |
| Lambda languages | Node.js, Python, Java, C#/Powershell, Ruby, Custom Runtime API; arbitrary Docker → ECS/Fargate |
| Lambda use cases | Thumbnails from S3 uploads, serverless cron jobs |
| API Gateway | Expose Lambda functions as an HTTP API; REST and WebSocket, throttling, API keys |
| AWS Batch | Batch jobs as Docker images on managed EC2/Spot via ECS; no time limit |
| Lightsail | Low, predictable pricing for simple app & DB stacks; HA but no auto-scaling |