CertNote/ Commute Study Notes
Roadmap
KOEN
CLF-C02 · FoundationalCloud Practitioner - Foundational
DVA-C02 · AssociateDeveloper - Associate
SAA-C03 · AssociateSolutions Architect - Associate
SOA-C02 · AssociateCloudOps Engineer - Associate
SAP-C02 · ProfessionalSolutions Architect - Professional
  • Week 1
    • 1.The Game Called the SAP Exam: Hands-On Techniques for Decomposing Scenarios
    • 2.IAM, STS, and Federation: Splitting the Word "Permission" into Six Layers
    • 3.The Anatomy of a VPC: What Route Tables Really Decide
    • 4.Four Compute Pillars in Depth: Revisiting Nitro, EBS, ELB, and Auto Scaling Through a Pro Lens
    • 5.Week 1 Integration: When IAM, VPC, and EC2 Meet in a Single Scenario
  • Week 2
  • Week 3
  • Week 4
  • Week 5
  • Week 6
  • Week 7
  • Week 8
    • 1.Lambda Advanced: Concurrency, Cold Starts, and SnapStart's Internal Operations
    • 2.Step Functions: State Model of Distributed Workflows and Saga Pattern
    • 3.EventBridge: Unified Model of Event Bus, Pipes, and Scheduler
    • 4.AppSync GraphQL and the Essence of SQS/SNS/Kinesis Messaging
    • 5.Week 8 Comprehensive — 12 Serverless & Event Architecture Scenarios
  • Week 9
  • Week 10
  • Week 11
  • Week 12
  • Week 13
  • Week 14
  • Week 15
  • Week 16
DOP-C02 · ProfessionalDevOps Engineer - Professional
Linux Master 2 · 2급KAIT Linux Master - Level 2
SCS-C03 · SpecialtySecurity - Specialty
Linux Master 1 · 1급KAIT Linux Master - Level 1
MLA-C01 · AssociateMachine Learning Engineer - Associate
AIF-C01 · FoundationalAI Practitioner - Foundational
DEA-C01 · AssociateData Engineer - Associate
MLS-C01 · SpecialtyMachine Learning - Specialty
SQLD · 개발자SQL Developer (SQLD)

© CertNote · 주간랩스

  • About
  • Changelog
  • Contact
  • Terms
  • Privacy
← SAP-C02/Week 8/Day 1

Based on the SAP-C02 exam guide·Report an error

SAP-C02· ProWeek 8 · Day 1~42 min read

Day 1 - Lambda Advanced: Concurrency, Cold Starts, and SnapStart's Internal Operations

When you first launch a Lambda function, everything feels magical. You upload code as a zip or point to a container image, and someone else automatically spins it up and scales it. But the moment traffic suddenly surges 10x in production, questions emerge: "Why did my response time jump from 50ms yesterday to 5 seconds today?" The answer is almost always one of three things: concurrency limits, cold starts, or VPC ENI exhaustion.

In the SAP-C02 exam, Lambda is the centerpiece of the serverless domain. Simple "event → function execution" problems rarely appear. Most questions focus on operational perspectives: "What's the most cost-efficient way to handle traffic spikes?", "How do I reduce cold starts without additional cost?", "How do I avoid ENI explosion when Lambda accesses RDS Proxy inside VPC?" Today, we examine the internal operations that create these operational challenges.

Firecracker and Lambda Execution Model — Why Micro VMs Were Chosen Over Containers

Many resources call Lambda a "container service," but technically it's not. Each function instance runs on a Firecracker micro VM atop its own Virtual Machine Monitor (VMM). Firecracker, which AWS open-sourced in 2018, was built to replace QEMU and reduced boot time to approximately 125ms.

Why micro VMs instead of containers (cgroups + namespaces)? The core reason is isolation strength in multi-tenant environments. Hundreds of customer functions can run side-by-side on a single bare metal server, but container-only isolation cannot prevent side-channel attacks (e.g., Spectre, Meltdown) due to kernel sharing. Firecracker runs on KVM while radically minimizing the device model, reducing VM boot overhead to container-like levels.

💡 Related Theory: Firecracker is detailed in the NSDI 2020 paper "Firecracker: Lightweight Virtualization for Serverless Applications." The key insight is that a minimal VMM (under 20,000 lines of Rust code) minimizes attack surface. The same technology powers Fargate, so "Lambda and Fargate are different abstractions over essentially the same isolation technology" is an accurate mental model. From a CS perspective, Lambda provides a stateless function abstraction while Fargate provides a stateful container abstraction, leading to different use cases.

🔍 Deeper Dive: Firecracker doesn't create new micro VMs for every invocation. AWS maintains a pool of Slots (pre-warmed micro VMs) on Workers (bare metal EC2 instances). When a cold start request arrives, AWS retrieves a Slot, injects function code, and executes init. Cold start time thus decomposes into: (1) Slot allocation — nearly 0 (2) Code download and decompression — proportional to zip/image size (3) Runtime bootup — Java JVM is heaviest (4) Init code execution — user responsibility. In exam questions asking "how to reduce cold start," the correct answer typically targets one of (2), (3), or (4).

Breaking Down the Three Types of Concurrency

Concurrency is one of Lambda's most confusing concepts. The same word is used with three different meanings.

TypeMeaningImpact
Account Concurrency Limit (Unreserved)A shared pool per region across all functions. Default 1,000 (soft limit).One runaway function throttles others
Reserved ConcurrencyReserve part of the pool for a specific function. Also acts as an upper limit.Isolation + upper bound
Provisioned Concurrency (PC)Maintain N pre-warmed (initialized) instances.Zero cold start, but costs apply

Reserved and PC can be used together. For example, "this function is Reserved=200, PC=50" means 50 instances are always warm, traffic above that scales up to 150 cold, and requests exceeding 200 are throttled.

⚠️ Trap: Exam options often say "Setting Reserved Concurrency means only N instances can run." More precisely, it guarantees N concurrent executions while acting as an upper limit. Reserved=10 means at most 10 simultaneous executions; beyond that is throttled. Overlooking the "upper limit" aspect leads to incorrect scenario analysis.

📚 Case Study: In 2019, a fintech company experienced Lambda payment processing throttling due to a nighttime batch function traffic spike. Both functions shared the same account concurrency pool (1,000); the batch function occupied 950 during one hour, leaving only 50 for payment processing, causing a ~30% payment failure rate. The fix: assign Reserved=500 to the payment function for isolation. The SAP exam's "one function affects another" scenario follows exactly this pattern.

Cold Start — Decomposing Causes Reveals Solutions

Lambda cold start time is cumulative, not a single number. By AWS official data, a Java 11 Lambda cold start breaks down as:

  • AWS Side (code download + Slot allocation + runtime bootup): 100~600ms
  • Init Code (user code class loading, DB connection pool initialization, etc.): 1~5 seconds (Java baseline)
  • First Handler Execution: 200~1,000ms (JIT warmup)

The largest component is Init Code. A Java Spring Boot function can lose 2~3 seconds loading thousands of classes. SnapStart is the tool to address this.

SnapStart's Operating Principle:

  1. When publishing a function version, AWS executes Init once.
  2. At that moment, AWS captures and encrypts the micro VM memory and disk state as a snapshot.
  3. On the next cold start, instead of re-executing init, the snapshot is restored via the CRaC (Coordinated Restore at Checkpoint) mechanism.
  4. After restoration, the handler executes immediately.

💡 Related Theory: CRaC is an official OpenJDK project that standardizes checkpoint and restore of Java JVM process state. It's based on CRIU (Checkpoint/Restore In Userspace), a Linux kernel feature. SnapStart adopted CRaC, first for Java, then extended to Python and .NET in 2024. The core model follows a general distributed systems optimization pattern: "initialize once, run infinitely."

🔍 Deeper Dive: SnapStart is free because AWS benefits from better compute efficiency. Executing init on every cold start costs more CPU, memory, and network than restoring a pre-built snapshot from page cache. However, a pitfall exists: the snapshot copies memory and disk state identically, so random seeds, unique IDs, and DB connection TCP states created during init are identical across all restorations. That's why SnapStart guidelines emphasize "don't generate uniqueness state during init," and provide Crac.Resource interface hooks for beforeCheckpoint/afterRestore.

⚠️ Trap: Enabling SnapStart breaks the stateless function assumption. For example, if init generates a UUID.randomUUID() as an instance ID for cache keys, all SnapStart restorations get the same ID, causing cache collisions. The exam doesn't ask directly, but it's a common real-world pitfall worth knowing.

VPC Integration and Hyperplane ENI — Before and After 2019

Lambda functions accessing RDS or ElastiCache inside VPC require VPC integration. Before 2019, Lambda VPC integration was notoriously problematic: each new concurrent execution attached a new ENI, and ENI creation took 10~15 seconds. With 100 concurrent executions, 100 ENIs were created, hitting VPC ENI limits (typically ~5,000 per subnet), causing function timeouts.

In September 2019, AWS completely redesigned this with the Hyperplane ENI architecture. Hyperplane is an AWS internal network virtualization layer (also powering VPC, NAT GW, NLB) operating as follows:

  1. On first use of a function and VPC/Subnet/SG combination, a single cross-account ENI is created.
  2. That ENI is shared by function instances. Even 100 concurrent executions typically end with just a few ENIs.
  3. When the function becomes inactive, the ENI persists briefly before garbage collection.

This change made VPC Lambda cold starts nearly identical to non-VPC cold starts. Exam questions like "how do I avoid ENI explosion with Lambda VPC integration" are now rare, but understanding "ENI count per function is not proportional to concurrency" remains operationally important.

🔍 Deeper Dive: Hyperplane acts as a distributed NAT/LB layer inside AWS, similar to systems like Andromeda. NLB, PrivateLink, Lambda VPC ENI, NAT Gateway, and S3 Gateway Endpoint all run on Hyperplane. This means Lambda VPC integration "uses subnet IPs but actual traffic routes through Hyperplane" is the architectural insight. The AWS re:Invent 2019 session "A Serverless Journey: AWS Lambda Under the Hood" is the best primary source.

🎯 Scenario: "A company sends 500 queries/second from a Lambda to a VPC RDS PostgreSQL with max_connections=200. When concurrent executions grow to 1,000, 'too many connections' errors appear. Best solution?" — Answer: RDS Proxy. The Lambda → RDS Proxy → RDS pattern applies connection multiplexing (pooling), binding 1,000 Lambda instances to ~50 RDS connections. Additionally, RDS Proxy provides IAM auth and connection holding during failover. Exam keywords "Lambda + RDS + concurrency + connection error" almost always point to RDS Proxy.

Asynchronous Invocation's Retry Model and Destinations

Lambda invocations come in three types — synchronous, asynchronous, and stream-based — each with different retry models.

Invocation ModelCallerRetries
Synchronous (Sync)API GW, ALB, Function URL, direct invokeCaller's responsibility (Lambda doesn't retry)
Asynchronous (Async)S3 Event, SNS, EventBridgeLambda auto-retries 2x (3 total attempts)
Stream PollSQS/Kinesis/DDB StreamsESM retries + DLQ/PartialBatch

Failure handling for async invocations uses two approaches: DLQ (legacy, function execution failures only) and Destinations (2019, routes success and failure). Destinations are recommended, supporting four targets (Lambda, SNS, SQS, EventBridge).

📚 Case Study: In 2020, an e-commerce company ran an S3 → Lambda (image resize) pipeline with DLQ but struggled tracking "at which stage and with what input did failure occur?" Switching to Destinations, sending OnFailure to EventBridge, the failure event contained original input + response payload + execution context, simplifying analysis. DLQ preserves only the payload without context.

Function URL — Bypassing API Gateway for Simple HTTPS

Function URL, launched in 2022, provides direct HTTPS endpoints to Lambda functions. Access is possible without API Gateway via https://.lambda-url..on.aws. Authentication is NONE or IAM (AWS_IAM). CORS and CloudFront front-end are supported.

When to use:

  • Single function not worth API GW overhead (simple webhook receiver, status endpoint, etc.)
  • Wanting to reduce API GW costs (API GW costs $3.50/M per invocation; Function URL has no per-invocation cost — only Lambda invocation charges)
  • Caching behind CloudFront

When not to use:

  • API GW features needed (API keys, throttle, JWT validation)
  • Non-REST protocols like WebSocket or SOAP
  • Routing multiple functions under one domain

⚠️ Trap: Function URL supports only IAM authentication, not Cognito User Pool integration. JWT-based user authentication requires API GW + Cognito Authorizer. In exams, "Cognito user auth + Lambda" scenarios almost always point to API GW.

Lambda Packaging — Layer vs Container Image

Function packaging supports two approaches.

MethodSize LimitUse Case
zip + Layerzip 50MB (direct) / 250MB unzipped (S3), 5 layers maxGeneral functions + shared libraries
Container Image (OCI)10GBML models, large binaries (ffmpeg, headless Chrome), existing container workflows

Container Image pushes to ECR, then Lambda unpacks the image into the micro VM. The 10GB limit is large, but cold start can be longer (image pull time). However, Lambda uses layer-wise lazy loading, downloading only what's needed for first execution, reducing startup. This is detailed in the SOSP 2023 paper "Faster Cold Starts for Lambda with On-Demand Code Loading."

🔍 Deeper Dive: Lambda doesn't use the ECR original directly; instead, AWS stores the image in an internal distributed cache with block-level deduplication. If 10,000 functions use the same base image (e.g., public.ecr.aws/lambda/python:3.11), storage is consumed only once. During cold start, the entire image is not downloaded; only blocks needed for function execution are lazy-fetched. This enables even 10GB images to start first invocation in 200~500ms.

Graviton2/3 (ARM) — 20% Savings Nearly Free

Lambda supports two architectures: x86_64 and arm64. arm64 (Graviton2) is ~20% cheaper and 19% faster. Without compatibility issues, ARM is almost always the answer.

When ARM cannot be used:

  • Native binaries (x86-only .so/.dll) in libraries
  • Some ML inference libraries (especially NVIDIA CUDA dependent)
  • Container images not built multi-arch

Most Node.js/Python/Go/Java functions migrate to ARM unchanged. In SAP exams, "cost optimization" + "Lambda" keywords make ARM migration the first candidate.

Lambda Burst Concurrency — The Limit on Sudden Traffic

Lambda doesn't scale to its concurrency limit (e.g., 1,000) instantly from 0. A Burst Concurrency initial spike limit exists, varying by region:

  • us-east-1, us-west-2, eu-west-1: 3,000 burst
  • ap-northeast-1, eu-central-1 and other major regions: 1,000 burst
  • Other new regions: 500 burst

Beyond this, scaling increases +500 per minute gradually. So a workload needing 0 → 5,000 concurrent executions in under 5 minutes will face throttling (HTTP 429) for the first few minutes. To avoid this, pre-warm with Provisioned Concurrency.

🎯 Scenario: "Black Friday sale happens once monthly; 50x traffic surge in 5 minutes. Lambda must handle without throttle." — Answer: Use Application Auto Scaling to increase Provisioned Concurrency on schedule. Raise PC=2000 30 minutes before sale start, then reduce PC=10 after. PC charges per-hour, but throttle avoidance and consistent latency are worth more.

Summary

On the surface, Lambda promises "just write code and it runs," but production operations are shaped by micro VM isolation, Hyperplane ENI, CRaC snapshots, and concurrency pooling, all determining cost and latency. Frequently tested exam scenarios map to four categories: "cold start (SnapStart vs PC vs init optimization)," "concurrency isolation (Reserved)," "VPC + DB connections (RDS Proxy)," and "ARM migration."

Next day, we'll see Step Functions, which lets you chain Lambda functions into workflows. The key next topic is how Step Functions supplements Lambda's limits (15-minute timeout, simple retry model).

📝 Practice Questions

Click a choice to reveal the answer and explanation.

Question 1

The cold start of a Java 17 Spring Boot-based Lambda function averages 4 seconds. The operations team wants to reduce it to 1 second or less at no additional cost. What is the most appropriate method?

Question 2

A payment processing Lambda function is throttled because of traffic spikes from another analytics batch Lambda. Both functions run in the same AWS account. How can you guarantee and isolate a minimum of 500 concurrent executions for the payment function?

Question 3

A Lambda function connects to RDS PostgreSQL in a VPC. As concurrent executions rise to 1,500, a "FATAL: too many connections" error occurs. RDS max_connections is 200. What is the most appropriate solution?

Question 4

In an S3 → Lambda asynchronous invocation pipeline, you want to analyze the original payload, response, and execution context of failed events. What is the most appropriate configuration?

Question 5

An ML inference function includes 1.8 GB of PyTorch model weights. This exceeds the 250 MB unzipped limit of zip-based Lambda. It must also operate properly at 100 concurrent executions. What is the most appropriate packaging?

Question 6

When a Black Friday sale starts, Lambda surges from 0 to 5,000 concurrent executions within 5 minutes. The us-east-1 burst limit is 3,000, and after that it grows gradually by +500 per minute. How can you absorb the traffic without throttling?

Question 7

A Lambda function runs Python 3.11 and uses only NumPy/Pandas. The operations team wants a 20% cost reduction. What is the simplest change?

📌 Today's Summary

  1. Firecracker micro VM isolation, warmed up from a slot pool → cold start decomposition (download/runtime/Init/JIT)
  2. Three kinds of concurrency: account limit (1,000 default) / Reserved (isolation + cap) / Provisioned (warm, incurs cost)
  3. SnapStart (CRaC-based) — Java/Python/.NET, free, watch init uniqueness
  4. Hyperplane ENI (2019~) — ENIs are shared for VPC integration, RDS Proxy resolves connection surges
  5. Asynchronous retries: 2 automatic retries + rich routing with Destinations (SNS/SQS/EB/Lambda)
  6. Function URL — simple HTTPS that bypasses API GW, IAM authentication only
  7. Container Image 10 GB + block-level lazy loading, Graviton2 ARM 20% savings
  8. Burst Concurrency limit (us-east-1 = 3,000) → for predictable spikes, PC + Auto Scaling
PreviousWeek 7 Wrap-Up — Cementing It with 12 Container Scenario QuestionsWeek 7 · Day 5Next Step Functions: State Model of Distributed Workflows and Saga PatternWeek 8 · Day 2

Official references

  • SAP-C02 official exam page(opens in a new tab)
  • AWS Lambda documentation(opens in a new tab)
  • Amazon VPC documentation(opens in a new tab)
  • Amazon RDS · Aurora documentation(opens in a new tab)
  • AWS IAM documentation(opens in a new tab)
  • Amazon S3 documentation(opens in a new tab)

On this page

  • Firecracker and Lambda Execution Model — Why Micro VMs Were Chosen Over Containers
  • Breaking Down the Three Types of Concurrency
  • Cold Start — Decomposing Causes Reveals Solutions
  • VPC Integration and Hyperplane ENI — Before and After 2019
  • Asynchronous Invocation's Retry Model and Destinations
  • Function URL — Bypassing API Gateway for Simple HTTPS
  • Lambda Packaging — Layer vs Container Image
  • Graviton2/3 (ARM) — 20% Savings Nearly Free
  • Lambda Burst Concurrency — The Limit on Sudden Traffic
  • Summary
  • Practice Questions
  • Today's Summary