03 · AWS Lambda Concept Map: 6 Core Concepts and 6 Key Components
中文版 GitHub: https://github.com/geekchow/aws-lambda-guideWhere you are:Stage 3 of 6 (Concept map).After this file you will know:Lambda’s 6 core concepts (in dependency order), its 6 key player components (owns / knows / does not do), and how they coordinate on one diagram. No internals yet — those come in the depth dives.3.1 Domain mapping — from problem to conceptsIntroduced in dependency order: each concept only uses the ones above it.#Real-world problem elementLambda conceptOne-line definitionWhy this abstraction1“A piece of business logic triggered by an event”FunctionA named unit of code configuration (runtime, handler, memory, timeout, env vars, IAM (Identity and Access Management) role).The unit you deploy and pay for — no server in the abstraction.2“A server to run that logic on”Execution environmentAn isolated Firecracker microVM (micro Virtual Machine) holding one copy of the function, servingone request at a time, reused across requests, then retired.Replaces the long-lived server with a disposable, request-sized sandbox.3“How much load there is right now”Invocation concurrencyAninvocationis one execution of the handler;concurrencyis the number of invocations in flight number of busy environments. ≈ RPS (Requests Per Second) × average duration.Turns capacity planning into one number the platform can measure and limit.4“A release”VersionAnimmutable, numbered snapshot of the function’s code configuration (1,2, … ).$LATESTis the one mutable draft.Lambda must recreate identical environments at any time; it needs a frozen artifact to do so.5“The release that production uses”AliasAmutable named pointer(prod,staging) to one version, or to two versions with traffic weights.Callers bind to a stable name; deploys and rollbacks become pointer flips.6“Servers already booted before the rush”Provisioned concurrency (PC)A number of execution environments Lambda keepsinitialized in advancefor a specific version or alias.Removes cold starts from the request path for latency-critical code.Derived concepts(built from the core six, defined in the dives):Cold start an invocation that had to create initialize an environment (concepts 2 3). → 05.6Reserved concurrency a per-function floorandceiling carved out of the account’s concurrency pool (concept 3). → 05.4Qualifier / qualified ARN (Amazon Resource Name)function:checkout:7orfunction:checkout:prod(concepts 4 5). → 05.1Spillover an invocation that exceeded PC and ran on-demand (concepts 3 6). → 05.3How the concepts relate:has one mutablepublish-versionfreezes intopoints to 1 or 2weightedconfigured onpre-createsis the imageloaded intonames a qualifieroccupies 1 env 1 unit of concurrencyFunction$LATESTVersion NimmutableAlias prodProvisionedconcurrencyExecutionenvironmentsInvocationCaption: how a request reaches running code — invocation → alias → version → environment, with PC pre-creating environments.3.2 Key players — from concepts to componentsTwo of the players arecontrol-planeartifacts you manage (versions, aliases, PC config); the rest aredata-planeservices that serve each invocation. This table is the table of contents for Stage 5.#Key playerOwnsKnowsDoesnotdo1Version store(PublishVersion)Freezing$LATESTinto immutable, numbered snapshotsCode hash (CodeSha256), full config per version, the monotonically increasing version counterNever lets you edit a published version; never reuses a number; doesn’t decide which version gets traffic2Alias routerResolving a stable name to a concrete version per request (incl. weighted coin-flip)Alias → primary version optional second version and weightDoesn’t hold code, doesn’t run anything, doesn’t health-check (CodeDeploy/alarms do)3PC manager( Application Auto Scaling)KeepingNinitialized environments ready for a version/aliasRequested vs. allocated PC, status (IN_PROGRESS/READY/FAILED), utilizationDoesn’t cap traffic (overflow spills to on-demand); doesn’t auto-scale by itself — Application Auto Scaling does4Invoke Frontend Counting serviceAdmitting each request: authenticate, authorize, resolve qualifier, check concurrency limitsFunction metadata cache, current concurrency per function/account, reserved concurrencyDoesn’t run code; doesn’t choose a specific environment5Assignment Placement servicesMatching a request to a warm idle environment — or getting a new one created on a workerEvery environment’s state (idle/busy/initializing) and lease; worker capacityDoesn’t decide limits (Counting did); doesn’t execute code6Execution environment(Firecracker microVM on a worker)Running Init once and then the handler, one request at a timeYour process memory,/tmp, runtime, extensionsDoesn’t handle two requests at once; doesn’t persist anything beyond its own lifetimeArchitecture layers — question it answers: which player lives in which plane?Data plane: per invocationControl plane: configured by yourouting tableartifact configpre-create N envs1 Version store2 Alias config3 PC manager Application Auto Scaling4 Invoke Frontend Counting service5 Assignment Placement6 Execution environmentson workers3.3 Coordination at a glanceQuestion it answers: how does one synchronous request become a response, end to end?Execution env(microVM)Placement serviceAssignment serviceCounting serviceInvoke Frontend alias resolutionCaller(API Gateway)Execution env(microVM)Placement serviceAssignment serviceCounting serviceInvoke Frontend alias resolutionCaller(API Gateway)alt[warm idle env (PC or reused)][none idle → cold start]Invoke checkout:prod (payload)1AuthN/AuthZ, resolve prod → version2reserve 1 concurrency unit3OK (or 429 throttle)4need env for checkout:v85env-123 on worker W6create env for v87boot microVM, run Init8env-456 ready9env-45610deliver event11handler result12release unit13200 response14Caption: the happy path — admit, resolve, find-or-create an environment, run, release.Important non-happy flows (mechanics in the dives):Throttle— Counting service refuses: account or reserved concurrency exhausted, or the scaling rate is exceeded →429 TooManyRequestsException. → 05.4Spillover cold start— PC pool fully busy → on-demand environment created via Placement. → 05.3, 05.5Canary rollback— alias weight set back to 0 for the bad version. → 05.2ConclusionSix concepts — function, environment, concurrency, version, alias, PC — and six players are the whole map. Control-plane players decidewhatruns (version),under which name(alias), andhow much is pre-warmed(PC);>