SkillSprout
Chapter 8 · Lesson 3
Advanced
6 min read

Serverless and Container Platforms: API Gateway, Fargate, App Runner and Copilot

Overview

Serverless and container platforms shift undifferentiated work, such as patching hosts and capacity planning, to AWS. The DOP-C02 guide lists API Gateway, Lambda, Fargate, App Runner, Copilot, the Serverless Application Repository, EKS Distro, ROSA and App2Container because a DevOps engineer must pick the platform that fits the team and automate deployment onto it.

Think of choosing how to run a food stall. A Lambda function is a pop-up cart that exists only while serving; Fargate is a rented kitchen where you bring recipes (containers) but not the building; App Runner is a franchise that takes your source or image and runs it with minimal setup; EC2/EKS is leasing the whole building.

You are expected to choose by control, scale, cost and operational burden, and to configure concurrency, throttling, timeouts and networking correctly.

Key Concepts

  • API Gateway offers REST, HTTP and WebSocket APIs with stages, throttling, usage plans, authorisers (IAM, Cognito, Lambda), caching, canary release and private endpoints; HTTP APIs are cheaper and faster, REST APIs have more features.
  • Lambda scales per request with burst limits; reserved concurrency caps and guarantees a function's share, provisioned concurrency removes cold starts, and SnapStart speeds Java startup.
  • Fargate runs ECS tasks or EKS pods without managing instances; sizing is by vCPU and memory per task, with Fargate Spot for interruption-tolerant work.
  • AWS App Runner deploys from source or an ECR image with automatic build, load balancing, TLS and auto scaling (concurrency based) for web apps and APIs.
  • AWS Copilot CLI scaffolds and deploys ECS/Fargate and App Runner applications with CloudFormation pipelines under the hood.
  • Serverless Application Repository publishes and shares SAM applications across accounts or publicly; consumers deploy them as nested CloudFormation stacks.
  • EKS Distro is the open-source Kubernetes distribution used by EKS for self-managed or on-premises clusters; ROSA is managed Red Hat OpenShift on AWS.
  • App2Container containerises existing .NET and Java applications and generates ECS/EKS artifacts and CI/CD.

Detailed Notes

Platform selection

RequirementBest fitWhy
Event-driven code, short tasks, scale to zeroLambdaPay per request, no servers
Containers, no infrastructure managementECS on Fargate or EKS on FargatePer-task billing, isolation
Simple web app from source/image, minimal AWS knowledgeApp RunnerAuto build, TLS, scaling
Kubernetes APIs and ecosystemEKSManaged control plane
Existing OpenShift platformROSAJoint Red Hat and AWS support
Kubernetes on premises with AWS tooling parityEKS Distro / EKS AnywhereSame distribution
Lift legacy .NET/Java VM app into containersApp2ContainerAutomated containerisation
GPUs, special kernels, full host controlEC2 (ECS/EKS on EC2)Maximum control

API Gateway features to know

FeatureREST APIHTTP API
Usage plans and API keysYesNo
CachingYesNo
Request validation, WAFYesWAF no (use CloudFront+WAF)
JWT authoriser built inNo (use Cognito/Lambda)Yes
Private endpointYesNo (use VPC link to private)
CostHigherAbout 70% cheaper

Stages carry stage variables and canary settings (route a percentage of traffic to a new deployment). Throttling defaults to 10,000 requests per second and 5,000 burst per account per Region and can be tuned per method and usage plan. Integration timeout for REST APIs is 29 seconds by default, so long jobs must be asynchronous (return 202 and use SQS or Step Functions).

Lambda scaling controls

ControlEffect
Reserved concurrencyLimits and reserves capacity for a function; protects downstream
Provisioned concurrencyPre-initialised environments for low latency; can be scheduled with Application Auto Scaling
Event source max concurrencyCaps SQS poller concurrency
Timeout and memoryMemory also sets CPU share; tune with Lambda Power Tuning
VPC configurationNeeds private subnets with NAT or VPC endpoints for internet/API access
yaml
Resources:
  ApiFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: app.handler
      Runtime: python3.12
      MemorySize: 512
      Timeout: 15
      AutoPublishAlias: live
      ProvisionedConcurrencyConfig: { ProvisionedConcurrentExecutions: 5 }
      ReservedConcurrentExecutions: 50
      Events:
        Get:
          Type: HttpApi
          Properties: { Path: /items, Method: GET }

Containers on Fargate and App Runner

  • Fargate task definitions specify CPU and memory combinations, an execution role (pull images, write logs) and a task role (application permissions). Ephemeral storage defaults to 20 GiB (up to 200); mount EFS for persistence.
  • ECS Service Connect or Cloud Map provides service discovery; ALB target groups handle external traffic; deployments can use rolling, CodeDeploy blue/green or ECS native blue/green.
  • App Runner services connect to a VPC through a VPC connector for private databases and scale on concurrent requests per instance.
bash
copilot init --app shop --name api --type "Load Balanced Web Service" --dockerfile ./Dockerfile
copilot env deploy --name prod
copilot pipeline init && copilot pipeline deploy

Sharing serverless apps

Publish a SAM template to the Serverless Application Repository (sam publish) with a resource policy sharing it with specific accounts or an organisation; consumers deploy with a CloudFormation stack that references the application. This suits internal reusable building blocks such as log forwarders and Slack notifiers.

Operations considerations

  • Observability: enable X-Ray and Application Signals, structured logs and Container Insights for ECS/EKS.
  • Security: least-privilege task and function roles, private integrations, secrets from Secrets Manager or Parameter Store, image scanning in ECR.
  • Quotas: account concurrency (default 1,000 Lambda), Fargate task limits, API Gateway throttles; request increases ahead of launches.

Real World Example

Scenario: a startup runs a public API, a nightly batch and an internal admin portal. The API uses API Gateway HTTP APIs with Lambda and provisioned concurrency for the latency-critical route. Nightly batch jobs run as Fargate tasks launched by Step Functions, with Fargate Spot to reduce cost.

The small admin web app is deployed from a Git repo to App Runner with a VPC connector. A shared notification component is published in the Serverless Application Repository so all teams deploy the same tested version.

Architecture Diagram

Matching workloads to platforms
Architecture
AWS Cloud
Clients
API Gateway

Compute options

LambdaEvent-driven
FargateContainers
App RunnerSource to URL

Serverless functions, managed containers and app-level platforms behind one edge.

  1. 1Clients call API Gateway, which enforces auth and throttling.
  2. 2Latency-sensitive routes invoke Lambda with provisioned concurrency.
  3. 3Long-running or custom runtimes run on Fargate behind a load balancer.
  4. 4Simple web apps deploy to App Runner from Git or an image.
  5. 5Shared building blocks are distributed through the Serverless Application Repository.

Best Practices

  • ✓Choose the most managed platform that meets requirements and avoid managing hosts without a reason.
  • ✓Set reserved concurrency and API throttles to protect downstream systems.
  • ✓Return 202 and process asynchronously for work longer than API Gateway timeouts.
  • ✓Separate task execution roles from task roles and use VPC endpoints for private access.
  • ✓Publish reusable serverless components with SAM and the Serverless Application Repository.

Common Interview Questions

Exam Tips

DOP-C02 focus

  • "No servers to manage, containers" = Fargate; "just give AWS my code or image" = App Runner.
  • "Cold start latency" = provisioned concurrency (or SnapStart for Java).
  • "Protect a database from Lambda scale" = reserved concurrency or SQS max concurrency.
  • "Share SAM apps across accounts" = Serverless Application Repository.

Finished this lesson?

0 of 44 lessons done · 0% of the course