Solutions Architect

Serverless and containers

Serverless technologies and container orchestration belong to task 3.2 of Design High-Performing Architectures, 24% of the scored content: who manages the servers, how fast it scales and what it costs.

Lambda

AWS Lambda

Official page

Runs code in response to events with no servers to manage. Designed for short-lived tasks that keep no state between invocations.

Key points

  • Memory and CPU: 128 MB to 10,240 MB in 1 MB steps. CPU is allocated in proportion to memory, and 1,769 MB equals 1 vCPU. More memory is the main lever for CPU-bound or network-bound functions.
  • Timeout: up to 900 seconds (15 minutes) per invocation.
  • Payloads: 6 MB for synchronous request and response, 1 MB for asynchronous events. Environment variables total 4 KB.
  • Packaging: .zip up to 50 MB zipped and 250 MB unzipped with layers, or a container image up to 10 GB. /tmp from 512 MB to 10,240 MB.
  • Layers: up to 5 per function, extracted to /opt, to share libraries across functions. Only for .zip functions, not container images.
  • Tuning: AWS Lambda Power Tuning and AWS Compute Optimizer help pick the memory setting.

On the exam

"CPU-bound function is slow" -> raise memory (CPU follows). "Processing takes 40 minutes" -> not Lambda, use ECS on Fargate or AWS Batch. "Same library in many functions" -> layers.

Concurrency

Lambda concurrency

Official page

Concurrency is average requests per second times average duration. Functions in a Region share 1,000 concurrent executions by default, a quota that can be raised.

Key points

  • Reserved concurrency: a slice of the pool that is both the guaranteed minimum and the maximum for the function. Protects critical functions or caps one that would overload a downstream resource. No charge.
  • Provisioned concurrency: pre-initialized execution environments that answer without cold starts. Extra charge, and it can follow a schedule or utilization through Application Auto Scaling.
  • Limits: each function scales by up to 1,000 execution environments every 10 seconds. Lambda keeps 100 units unreserved, so 900 of the default 1,000 can be reserved. Requests per second are capped at 10 times the concurrency.
  • SnapStart: snapshots the initialized environment when a version is published and resumes from it, with startup as low as sub-second. Java 11+, Python 3.12+ and .NET 8+. Free on Java, caching and restore charges on the others.
  • SnapStart limits: published versions only, and no combination with provisioned concurrency, EFS or /tmp above 512 MB.

On the exam

"Cold starts unacceptable on a latency-sensitive API" -> provisioned concurrency (or SnapStart for Java, Python, .NET). "A function overwhelms the database" -> reserved concurrency as a cap.

Official page

Services either push events to Lambda through triggers, or Lambda polls them through an event source mapping that reads batches.

Key points

  • Triggers (push): S3, SNS, API Gateway and others invoke the function as soon as the event happens. The trigger is configured and stored on the source service.
  • Event source mappings (poll): Lambda pollers read SQS, Kinesis, DynamoDB, Amazon MSK, self-managed Kafka, Amazon MQ and DocumentDB and invoke the function with batches of records.
  • Batching: a batch closes at the batch size, at the batching window (0 to 300 seconds) or at 6 MB of payload. Larger batches spread the invoke overhead and raise throughput.
  • At least once: mappings can process a record more than once, so make the handler idempotent. On error, stream batches are retried and the shard pauses to keep order.
  • Provisioned mode: dedicated pollers with a minimum and maximum for SQS, Amazon MSK and Kafka mappings, when latency must stay consistent. Extra charge.

On the exam

"Process SQS messages with Lambda in batches" -> event source mapping. "Run code when an object arrives in S3" -> S3 event notification trigger. "Duplicates broke the results" -> make the handler idempotent.

ECS vs EKS

Amazon ECS and Amazon EKS

Official page

Both orchestrate containers on EC2, Fargate or on premises. The choice comes down to whether you want Kubernetes.

Key points

  • Amazon ECS: AWS-native orchestrator with no control plane to run. A task definition is the blueprint, a task runs it, and a service keeps the desired number of tasks running.
  • Amazon EKS: managed, certified Kubernetes-conformant control plane. Reuses Kubernetes manifests, tools and skills, and keeps workloads portable.
  • EKS Auto Mode: AWS also manages the nodes, including provisioning, instance selection, scaling and OS patching.
  • Scaling: ECS Service Auto Scaling changes the number of tasks, and Cluster Auto Scaling changes the EC2 instances registered to the cluster.
  • Cost: ECS orchestration has no additional charge. EKS adds a per-cluster charge on top of the compute.

On the exam

"Team already runs Kubernetes and wants a managed control plane" -> EKS. "Simplest AWS-native container orchestration with least overhead" -> ECS, usually on Fargate.

ECS or EKS

CriterionECS and EKS
APIECS: AWS-native concepts. EKS: standard Kubernetes.
Control planeECS: nothing to run or upgrade. EKS: managed by AWS, but you follow Kubernetes version upgrades.
CapacityBoth: EC2, Fargate and on-premises options (ECS Anywhere, EKS Anywhere, EKS Hybrid Nodes).
Best forECS: least operational effort on AWS. EKS: Kubernetes skills, tooling or portability.

Fargate vs EC2

AWS Fargate

Official page

The capacity under ECS or EKS. Fargate runs each task with no servers to manage, while the EC2 launch type runs tasks on instances you manage.

Key points

  • Fargate: you set CPU and memory per task, and each task has its own isolation boundary with no shared kernel, CPU, memory or network interface. Billed per second for vCPU, memory and storage, with a 1-minute minimum on Linux.
  • Task sizes: from 0.25 vCPU with 512 MiB up to 32 vCPU with 244 GB on Linux. 20 GB of ephemeral storage is included.
  • Networking: always awsvpc mode with one network interface per task, so load balancer target groups use the ip target type.
  • Fargate Spot: up to 70% off for interruption-tolerant ECS tasks, with a 2-minute warning. Linux only.
  • EC2 launch type: you manage instances, AMIs and cluster capacity, and in return get GPUs, privileged containers and any instance type, none of which Fargate supports.

On the exam

"Run containers without managing or patching servers" -> Fargate. "Containers need GPUs or privileged mode" -> EC2 launch type. "Cheap, interruptible container jobs" -> Fargate Spot.

Fargate or EC2 capacity

AspectFargate and EC2
ServersFargate: none to manage. EC2: you choose, patch and scale instances.
BillingFargate: per task vCPU, memory and storage. EC2: per instance, used or not.
IsolationFargate: one boundary per task. EC2: tasks share the instance.
FeaturesFargate: no GPU, no privileged mode. EC2: GPUs, privileged mode, any instance type.
Official page

Amazon ECR stores the images that ECS, EKS and Lambda pull. Moving an application into containers starts with building an image and pushing it to ECR.

Key points

  • Registry: private repositories with IAM resource-based permissions, plus ECR Public. Docker images, OCI images and OCI artifacts.
  • Image scanning: scan on push to find software vulnerabilities in each new image.
  • Lifecycle policies: rules that clean up unused images, testable before they apply.
  • Replication and cache: cross-Region and cross-account replication, and pull through cache rules that keep upstream images in your private registry.
  • Containerizing: package the app and its dependencies in an image, push it to ECR, describe it in a task definition or pod spec, and run it on Fargate or EC2. The same image runs the same way in every environment.
  • Private pulls: tasks in private subnets pull from ECR through an interface VPC endpoint instead of a NAT gateway.

On the exam

"Store and scan images, copy them to a DR Region" -> ECR with replication. "Fargate tasks in private subnets cannot pull images" -> add an ECR interface endpoint or a NAT gateway.

Containers on premises

ECS Anywhere and EKS Anywhere

Official page

The same orchestrators can manage servers in your own data center, for data that must stay local or for a gradual migration.

Key points

  • ECS Anywhere: registers on-premises servers or VMs as external instances of an ECS cluster (EXTERNAL launch type) through the SSM Agent. Charged per registered instance per hour.
  • ECS Anywhere limits: no load balancing, no service discovery, no awsvpc mode and no EFS volumes. Best for workloads that generate outbound traffic or process data.
  • EKS Anywhere: creates and operates Kubernetes clusters on your own infrastructure (VMware vSphere, bare metal, Nutanix, AWS Snow), even air-gapped. Open source and free, with optional Enterprise Subscriptions.
  • EKS Distro: the Kubernetes distribution used by Amazon EKS and the base of EKS Anywhere.
  • EKS Hybrid Nodes: on-premises and edge servers joined as nodes of an Amazon EKS cluster.

On the exam

"Run containers on premises, managed from the ECS console" -> ECS Anywhere. "Kubernetes in a disconnected data center" -> EKS Anywhere. "On-premises service needs inbound traffic through a load balancer" -> ECS Anywhere is a poor fit.

Choosing the model

Containers or serverless

Official page

Most designs mix both. The deciding factors are run time, control over the runtime, traffic shape and the operational effort the team can carry.

Key points

  • Lambda: event-driven or unpredictable traffic, tasks under 15 minutes, pay per request and duration, no OS or runtime to manage.
  • Fargate: long-running services or jobs in containers with no servers to manage, any language or binary inside the image.
  • ECS or EKS on EC2: GPUs, specific instance types, privileged access or full control of the hosts.
  • Decoupling: put SQS, SNS or EventBridge between components so each tier scales independently on its own metric.
  • AWS Serverless Application Repository: publish and deploy reusable serverless applications defined with AWS SAM templates, shared publicly or with specific accounts. No charge beyond the deployed resources.

On the exam

"Unpredictable traffic, no servers, pay only when it runs" -> Lambda. "Containerized service running 24/7 without host management" -> ECS on Fargate. "Reuse a published serverless app across accounts" -> Serverless Application Repository.