Skip to main content
  1. Home
  2. >
  3. AWS
  4. >
  5. SAP-C02
  6. >
  7. AWS SAP-C02 Exam Scenarios
  8. >
  9. Lambda Timeout Trade-offs vs Fargate | SAP-C02

Lambda Timeout Trade-offs vs Fargate | SAP-C02

Jeff Taakey
Author
Jeff Taakey
21+ Year Enterprise Architect | Multi-Cloud Architect & Strategist.

While preparing for the AWS SAP-C02, many candidates get confused by Lambda timeout limitations and when to migrate to containers. In the real world, this is fundamentally a decision about Compute Model Selection vs. Operational Overhead. The 15-minute Lambda hard limit isn’t a bugโ€”it’s a design constraint forcing you to choose the right tool. Let’s drill into a simulated scenario.

The Scenario
#

MediaTransformPro, a digital asset management company, operates an automated image processing pipeline. When creative teams upload high-resolution marketing images to an S3 bucket (raw-assets-bucket), the system automatically:

  1. Downloads the image from S3
  2. Applies AI-powered background removal and quality enhancement
  3. Generates multiple format variants (WebP, AVIF, optimized JPEG)
  4. Stores processed assets in a second S3 bucket (processed-assets-bucket)
  5. Updates image metadata (processing status, file sizes, CDN URLs) in a DynamoDB table

The original architecture used a Node.js application deployed as an AWS Lambda function, triggered by S3 ObjectCreated events. This worked flawlessly for 6 months.

The Problem: Marketing campaigns now require 8K resolution images (50-120 MB files). Processing a single image now takes 18-22 minutes due to the complex AI transformations. The Lambda function timeout is already configured to the maximum allowed value (15 minutes), causing 87% of new uploads to fail with timeout errors.

Key Requirements
#

  • Must prevent invocation failures for images requiring >15 minutes of processing
  • Must remain serverless (no EC2 instance management)
  • Must preserve the existing event-driven architecture (S3 triggers)
  • Minimize architectural complexity and operational overhead

The Options
#

Select TWO:

  • A) Containerize the application by creating a Docker image containing the Node.js processing code, and publish the image to Amazon Elastic Container Registry (ECR).

  • B) Create an Amazon ECS task definition with AWS Fargate launch type compatibility. Configure the task definition to use the ECR image. Modify the Lambda function to invoke an ECS task using this task definition when new files are uploaded to S3.

  • C) Create an AWS Step Functions state machine with a Parallel state to invoke the Lambda function, and increase the Lambda function’s provisioned concurrency.

  • D) Create an Amazon ECS task definition with EC2 launch type compatibility. Configure the task definition to use the ECR image. Modify the Lambda function to invoke an ECS task using this task definition when new files are uploaded to S3.

  • E) Refactor the application to store images on Amazon Elastic File System (EFS) and metadata in Amazon RDS. Modify the Lambda function to mount the EFS file share.

Correct Answer
#

Options A and B

Step-by-Step Winning Logic
#

This is a compute model migration problem disguised as a timeout issue. The solution requires two synchronized steps:

  1. Option A (Containerization): Package the existing Node.js application into a Docker container. This preserves all application logic while making it portable across compute platforms.

  2. Option B (Fargate Orchestration): Deploy the container using ECS with Fargate launch type, which provides:

    • No timeout limits (tasks can run for hours)
    • Serverless operation (no EC2 cluster management)
    • Event-driven invocation (Lambda remains the orchestrator)

The architecture flow:

  • S3 event โ†’ Lambda (lightweight orchestrator) โ†’ ECS Fargate task (heavy processing) โ†’ S3 + DynamoDB updates

Why this satisfies all constraints:

  • โœ… Eliminates timeout failures (Fargate has no 15-min limit)
  • โœ… Remains serverless (Fargate manages infrastructure)
  • โœ… Preserves event-driven design (Lambda as trigger broker)
  • โœ… Minimal refactoring (same application code)

๐Ÿ’Ž Professional-Level Analysis
#

This section breaks down the scenario from a professional exam perspective, focusing on constraints, trade-offs, and the decision signals used to eliminate incorrect options.

๐Ÿ” Expert Deep Dive: Why Options Fail
#

This walkthrough explains how the exam expects you to reason through the scenario step by step, highlighting the constraints and trade-offs that invalidate each incorrect option.

Prefer a quick walkthrough before diving deep?
[Video coming soon] This short walkthrough video explains the core scenario, the key trade-off being tested, and why the correct option stands out, so you can follow the deeper analysis with clarity.

๐Ÿ” The Traps (Distractor Analysis)
#

This section explains why each incorrect option looks reasonable at first glance, and the specific assumptions or constraints that ultimately make it fail.

The difference between the correct answer and the distractors comes down to one decision assumption most candidates overlook.

  • Why not C (Step Functions + Parallel State)?

    • Fatal flaw: Step Functions cannot extend Lambda’s 15-minute maximum timeout. Parallel states distribute work across multiple Lambda invocations but don’t extend individual execution time.
    • Provisioned concurrency only reduces cold startsโ€”it doesn’t change timeout limits.
    • Cost trap: You’d pay for provisioned concurrency 24/7 while still failing on large images.
  • Why not D (ECS with EC2 launch type)?

    • Violates serverless requirement: EC2 launch type requires managing an ECS cluster of EC2 instancesโ€”exactly what the company wants to avoid.
    • You’d handle instance provisioning, scaling, patching, and capacity planning.
    • Exam trap: The difference between Fargate (serverless) and EC2 launch types is a classic SAP-C02 distractor.
  • Why not E (EFS + RDS refactoring)?

    • Solves the wrong problem: Storage location doesn’t affect processing time. A 20-minute image transformation takes 20 minutes whether files are on S3, EFS, or local disk.
    • Introduces unnecessary complexity: Adds EFS mount targets, VPC networking, and RDS management without addressing the timeout constraint.
    • Cost inefficiency: EFS provisioned throughput + RDS instance costs exceed S3 + DynamoDB for this use case.

๐Ÿ’Ž Professional Decision Matrix

This SAP-C02 professional section is locked.
Free beta access reveals the exam logic.

100% Free Beta Access

๐Ÿ” The Solution Blueprint
#

This blueprint visualizes the expected solution, showing how services interact and which architectural pattern the exam is testing.

Seeing the full solution end to end often makes the trade-offsโ€”and the failure points of simpler optionsโ€”immediately clear.

graph TD
    S3[S3: raw-assets-bucket
8K Image Upload] -->|ObjectCreated Event| Lambda[Lambda Function
Lightweight Orchestrator
Max 15min, not used for processing] Lambda -->|RunTask API Call| ECS[ECS Fargate Task
Node.js Container
No timeout limit] ECR[ECR: Image Repository
mediaprocessor:latest] -.->|Pull Image| ECS ECS -->|1. Download| S3 ECS -->|2. Process AI Transforms
18-22 minutes| Processing[Background Removal
Format Conversion
Quality Enhancement] Processing -->|3. Upload Results| S3_Out[S3: processed-assets-bucket] ECS -->|4. Update Metadata| DDB[DynamoDB Table
Image Metadata] style Lambda fill:#FF9900,stroke:#232F3E,stroke-width:2px,color:#fff style ECS fill:#FF9900,stroke:#232F3E,stroke-width:3px,color:#fff style ECR fill:#FF9900,stroke:#232F3E,stroke-width:2px,color:#fff style S3 fill:#569A31,stroke:#232F3E,stroke-width:2px,color:#fff style S3_Out fill:#569A31,stroke:#232F3E,stroke-width:2px,color:#fff style DDB fill:#4053D6,stroke:#232F3E,stroke-width:2px,color:#fff

Diagram Note: Lambda acts as a lightweight event router (executes in <1 second), while the containerized application runs on Fargate without timeout constraints, maintaining the serverless operational model.

๐Ÿ’Ž Professional Decision Matrix

This SAP-C02 professional section is locked.
Free beta access reveals the exam logic.

100% Free Beta Access

๐Ÿ” The Decision Matrix
#

This matrix compares all options across cost, complexity, and operational impact, making the trade-offs explicit and the correct choice logically defensible.

At the professional level, the exam expects you to justify your choice by explicitly comparing cost, complexity, and operational impact.

Option Est. Complexity Est. Monthly Cost (10,000 images/mo, 20min avg) Pros Cons Verdict
A + B (Fargate) Medium (Dockerfile + ECS task def) $850-$1,200 (Fargate vCPU/mem hours: 10k ร— 20min ร— $0.04048/vCPU-hour for 1vCPU, 2GB) โœ… No timeout limits
โœ… Truly serverless
โœ… Pay-per-use
โœ… Code reuse
โš ๏ธ Slight cold start (image pull)
โš ๏ธ Requires containerization knowledge
โœ… CORRECT
C (Step Functions) Low (state machine JSON) $650 (Lambda: 10k ร— 15min ร— $0.0000166667/GB-sec + Step Functions state transitions) + 100% failure rate โœ… Easy to implement
โœ… Visual workflow
โŒ Does NOT solve timeout
โŒ Parallel states don’t extend Lambda limits
โŒ Provisioned concurrency waste
โŒ TRAP
D (ECS EC2) High (cluster management + ASG + AMI patching) $720-$950 (2ร— t3.large reserved + EBS) โœ… No timeout limits
โœ… Potentially lower cost at scale
โŒ Violates serverless requirement
โŒ Operational overhead
โŒ Capacity planning needed
โŒ INCORRECT
E (EFS + RDS) High (VPC config + mount targets + DB schema) $980+ (EFS provisioned throughput $0.30/GB + RDS db.t3.medium $60/mo) + still times out โš ๏ธ Centralized storage โŒ Doesn’t solve timeout
โŒ Expensive storage for images
โŒ Unnecessary refactoring
โŒ DISTRACTOR

FinOps Key Insight: At 10,000 images/month (20min avg processing), Fargate’s cost of ~$1,000/mo is justified because Lambda physically cannot complete the job. The alternative isn’t “cheaper Lambda”โ€”it’s complete system failure. The real comparison is Fargate ($1,000) vs. EC2 ECS cluster ($720 + operational labor costs for management).

๐Ÿ’Ž Professional Decision Matrix

This SAP-C02 professional section is locked.
Free beta access reveals the exam logic.

100% Free Beta Access

๐Ÿ” Real-World Practitioner Insight
#

This section connects the exam scenario to real production environments, highlighting how similar decisions are madeโ€”and often misjudgedโ€”in practice.

This is the kind of decision that frequently looks correct on paper, but creates long-term friction once deployed in production.

Exam Rule
#

For the SAP-C02 exam, when Lambda timeout is explicitly stated as the problem and ’no infrastructure management’ is required, look for ECS Fargate migration (containerize + Fargate task definition). Step Functions Parallel states do NOT extend Lambda timeouts.

Real World
#

In production, we’d implement additional optimizations:

  1. Cost Optimization:

    • Use Fargate Spot for non-critical processing (70% cost reduction, accepts interruptions)
    • Implement S3 Intelligent-Tiering for processed assets
    • Add CloudWatch Logs Insights to identify images that could use lightweight Lambda processing (sub-15min), routing only complex jobs to Fargate
  2. Performance Enhancement:

    • Pre-pull Fargate container images using ECS capacity providers to minimize cold starts
    • Use AWS Batch instead of raw ECS for better job queue management and automatic retry logic
    • Implement Step Functions as the orchestrator (not for parallel Lambda, but for Fargate task state management and error handling)
  3. Hybrid Approach:

    • Route images <10MB โ†’ Lambda (cost-effective for simple transforms)
    • Route images 10-50MB โ†’ Lambda with reduced quality settings
    • Route images >50MB โ†’ Fargate (necessary for quality preservation)
  4. Not Mentioned in Exam:

    • SLA considerations: Fargate cold starts (8-15 seconds for image pull) vs. Lambda cold starts (1-3 seconds)
    • Concurrency limits: Fargate task limits (default 1,000/region) vs. Lambda concurrency (default 1,000, can request increase to 10,000+)
    • Observability: ECS task execution role permissions for X-Ray tracing vs. Lambda’s built-in integration

The brutal truth: Many teams resist containerization due to perceived complexity, trying to “hack” Lambda with techniques like recursive invocations or external orchestrators. This technical debt compounds when they eventually hit the timeout wall. The correct decision is migrating to the right compute model early, not fighting the service’s design boundaries.

๐Ÿ’Ž Professional Decision Matrix

This SAP-C02 professional section is locked.
Free beta access reveals the exam logic.

100% Free Beta Access