Lambda

컴퓨팅 연관 문항 183개

서버 없이 이벤트에 반응해 코드를 실행. "운영 부담 최소화"의 단골 정답

이게 뭔가요? / What is this?

Lambda는 서버도 컴퓨터도 아니라, "이 코드를 실행해줘"라고 요청할 때만 잠깐 켜졌다 사라지는 실행 서비스(완전 관리형)입니다. 자판기에 동전을 넣어야 그 순간만 작동하는 것처럼, 이벤트가 들어올 때만 코드가 돌아가고 끝나면 흔적도 없이 사라지며 실행된 시간만큼만 요금이 매겨집니다.

개요 / Overview

Lambda는 서버를 프로비저닝하지 않고 코드를 실행하며 실행 시간만큼만 과금합니다. 문제에 "운영 부담을 최소화", "유휴 비용 없이", "관리형"이 나오면 Lambda가 강력한 후보입니다. 대신 15분 실행 제한이 결정적 제약이며, 이를 넘기면 ECS/Fargate·Batch·Step Functions로 넘어가야 합니다.

동작 원리 / How it works

Lambda는 요청이 올 때 컨테이너 형태의 실행 환경을 띄우고, 그 안에서 핸들러 함수를 호출한 뒤 잠시 살려 두다가 회수합니다. 처음 띄우는 순간이 콜드 스타트이고, 살아 있는 환경을 재사용하는 것이 웜 스타트입니다. 동시에 들어온 요청 수만큼 환경이 병렬로 늘어나므로, Lambda의 "확장"은 인스턴스를 키우는 게 아니라 실행 환경 개수가 늘어나는 것입니다.

과금은 (요청 수) + (할당 메모리 × 실행 시간)입니다. 메모리 슬라이더를 올리면 vCPU와 네트워크 대역폭이 비례해 함께 올라가므로, CPU 바운드 함수는 메모리를 두 배로 올려 실행 시간이 절반 이하로 줄면 총비용이 오히려 내려갑니다. 이 비직관적 관계가 성능·비용 문제에서 종종 정답 근거가 됩니다.

시험은 무엇을 보는가 / What the exam is testing

시험이 Lambda로 보는 것은 "관리형으로 대체할 수 있는가"를 알아보는 눈입니다. 크론 서버, 폴링 워커, 이미지 리사이즈 데몬처럼 사람이 EC2에 올려 관리하던 것들이 이벤트 + Lambda로 사라지는 패턴을 반복해서 묻습니다. 동시에 반대 방향의 판단력도 봅니다 — 15분 제한, 상태 유지 불가, VPC 콜드 스타트 같은 경계에 부딪히면 Fargate나 Batch로 넘어가야 한다는 것입니다.

시험 포인트 / Exam points

15분 실행 제한

최대 실행 시간은 900초입니다. "처리에 1시간이 걸린다" 같은 조건이 보이면 Lambda 선택지는 즉시 탈락시키고 ECS/Fargate 태스크나 AWS Batch를 고르세요. 여러 단계를 길게 이어야 하면 Step Functions로 오케스트레이션합니다.

동시성 두 가지

Reserved Concurrency는 특정 함수에 동시성 상한·전용 풀을 보장해 다른 함수가 계정 한도를 잡아먹지 못하게 합니다. Provisioned Concurrency는 실행 환경을 미리 데워 콜드 스타트를 없앱니다. "지연시간이 일정해야 한다" → Provisioned.

VPC 내 리소스 접근

Lambda를 VPC에 연결하면 Hyperplane ENI를 통해 프라이빗 서브넷의 RDS 등에 접근합니다. 단, VPC에 붙은 Lambda가 인터넷에 나가려면 NAT 게이트웨이가 필요하고, S3·DynamoDB는 게이트웨이 VPC 엔드포인트로 무료로 나가는 편이 낫습니다.

메모리가 곧 CPU

메모리를 128MB~10,240MB 범위에서 올리면 vCPU와 네트워크 대역폭이 비례해 함께 올라갑니다. CPU 바운드 함수는 메모리를 키우면 실행 시간이 줄어 오히려 총비용이 내려가는 경우가 많습니다.

자주 틀리는 함정 / Common traps

실행 시간이 15분을 넘는 시나리오에 Lambda를 고르는 것 — 900초는 조정 불가능한 하드 리미트입니다. "각 파일 처리에 30분", "야간 전체 재계산"이 보이면 즉시 후보에서 제외하세요.

VPC에 붙인 Lambda가 인터넷에 나갈 수 있다고 가정하는 것 — VPC에 연결하면 퍼블릭 인터넷 경로를 잃습니다. 외부 API 호출이 필요하면 NAT 게이트웨이가, S3·DynamoDB면 VPC 엔드포인트가 추가로 필요합니다.

/tmp나 전역 변수에 상태를 유지하는 설계 — 환경 재사용은 보장되지 않으므로 다음 호출에 데이터가 없을 수 있습니다. 상태는 DynamoDB·S3·ElastiCache로 빼야 합니다.

헷갈리는 것 구분하기 / Telling them apart

Reserved ConcurrencyvsProvisioned Concurrency

Reserved는 "이 함수가 쓸 수 있는 동시성의 상한과 몫"을 정하는 용량 배분 장치이고, Provisioned는 "미리 데워 둘 환경 개수"를 정하는 지연시간 장치입니다. 계정 한도를 한 함수가 독점하는 문제 → Reserved, 콜드 스타트로 응답이 튀는 문제 → Provisioned.

LambdavsFargate

실행 단위가 함수인가 컨테이너 이미지인가, 그리고 15분을 넘는가로 갈립니다. 기존 도커 이미지를 그대로 써야 하거나 장시간 상주해야 하면 Fargate입니다.

권장 아키텍처 패턴 / Reference pattern

S3 이벤트 알림 또는 API Gateway → Lambda → DynamoDB, 실패분은 SQS 데드레터 큐로
📝 이 개념 문제 풀기

AWS Lambda

Compute 183 related questions

Event-driven serverless compute; the usual answer to "least operational overhead"

이게 뭔가요? / What is this?

Lambda is not a server or a computer you can point to — it is a fully managed execution service that spins up only when you say "run this code" and disappears right after. Like a vending machine that only springs to life when you drop a coin in, it runs only in response to an event and bills you only for that brief moment of execution.

개요 / Overview

Lambda runs code without provisioning servers and bills only for execution time. When a question says "minimize operational overhead", "no idle cost", or "fully managed", Lambda is a strong candidate. The decisive constraint is the 15-minute limit — beyond it, move to ECS/Fargate, Batch, or Step Functions.

동작 원리 / How it works

Lambda spins up a container-like execution environment on demand, invokes your handler inside it, keeps it warm briefly, then reclaims it. The first spin-up is a cold start; reusing a live environment is a warm start. Concurrency scales by adding environments, so "scaling" in Lambda means more parallel environments, not bigger ones.

Billing is requests plus allocated memory multiplied by duration. Raising the memory dial raises vCPU and network bandwidth proportionally, so a CPU-bound function given twice the memory may finish in less than half the time and cost less overall. That counter-intuitive relationship is often the reasoning behind the correct answer.

시험은 무엇을 보는가 / What the exam is testing

Lambda tests whether you can spot what a managed service replaces. Cron boxes, polling workers, and image-resize daemons that people used to run on EC2 collapse into event plus Lambda, and the exam asks that repeatedly. It also tests the reverse judgement: when you hit the 15-minute cap, the lack of durable local state, or VPC cold starts, you must move to Fargate or Batch.

시험 포인트 / Exam points

15-minute execution limit

Hard cap is 900 seconds. If the scenario says processing takes an hour, eliminate Lambda and pick an ECS/Fargate task or AWS Batch. For long multi-step flows, orchestrate with Step Functions.

Two kinds of concurrency

Reserved Concurrency caps and reserves a pool for one function so others cannot exhaust the account limit. Provisioned Concurrency pre-warms environments to eliminate cold starts. "Consistent latency" → Provisioned.

Reaching resources inside a VPC

Attaching Lambda to a VPC gives it Hyperplane ENIs to reach private resources such as RDS. A VPC-attached Lambda needs a NAT gateway for internet egress, but S3 and DynamoDB are better reached free of charge through a gateway VPC endpoint.

Memory dial also buys CPU

Memory from 128 MB to 10,240 MB scales vCPU and network bandwidth proportionally. For CPU-bound functions, more memory often shortens runtime enough to reduce total cost.

자주 틀리는 함정 / Common traps

Choosing Lambda when the scenario runs longer than 15 minutes — 900 seconds is a hard limit that cannot be raised. "Thirty minutes per file" or "nightly full recompute" eliminates it immediately.

Assuming a VPC-attached Lambda can reach the internet — attaching to a VPC removes the public path. External API calls then need a NAT gateway; S3 and DynamoDB need VPC endpoints.

Keeping state in /tmp or module globals — environment reuse is not guaranteed, so the next invocation may not see it. State belongs in DynamoDB, S3, or ElastiCache.

헷갈리는 것 구분하기 / Telling them apart

Reserved ConcurrencyvsProvisioned Concurrency

Reserved allocates a ceiling and a share of concurrency (a capacity tool). Provisioned pre-warms a number of environments (a latency tool). One function starving the account → Reserved. Cold starts causing latency spikes → Provisioned.

LambdavsFargate

Decided by whether the unit is a function or a container image, and whether it exceeds 15 minutes. An existing Docker image or a long-lived process means Fargate.

권장 아키텍처 패턴 / Reference pattern

S3 event notification or API Gateway → Lambda → DynamoDB, with failures routed to an SQS dead-letter queue
📝 Practice this concept

AWS SAA Hub Pro는 독립 학습 자료이며 Amazon Web Services, Inc.의 공식 서비스가 아닙니다. 시험 정책과 서비스 사양은 AWS 공식 문서를 기준으로 확인하세요.