ladderlore
  • 输入服务名称,例如 S3 或 IAM。

服务 · Serverless · 基于 CLF-C02

AWS Lambda

Size memory, plan concurrency and cold starts, and know how each trigger calls a function.

本课尚未翻译,暂以英文显示。

你在云从业者中已学过

  • Runs code on events. No servers. Pay per request and run time.
  • Triggered by S3, API Gateway, SQS, EventBridge and more.
  • A run has a time limit.
阅读云从业者课程
  • Synchronous

    Called by
    API Gateway, load balancer
    On error
    The caller sees it and retries
  • Asynchronous

    Called by
    S3, SNS, EventBridge
    On error
    Two retries, then destination or DLQ
  • Poll-based

    Called by
    SQS, Kinesis, DynamoDB Streams
    On error
    Batch is retried. SQS message returns to the queue
How each kind of trigger calls a function.
  • Memory

    What it does
    Sets memory and CPU
    Use it to
    Speed up CPU-bound code
  • Reserved concurrency

    What it does
    Guarantees and caps a function
    Use it to
    Protect a database
  • Provisioned concurrency

    What it does
    Keeps environments ready
    Use it to
    Remove cold starts
  • SnapStart

    What it does
    Starts from a saved snapshot
    Use it to
    Cut cold starts in Java
Four settings that tune speed and concurrency.

1 / 2

  • Memory

    What it does
    Sets memory and CPU
    Use it to
    Speed up CPU-bound code
  • Reserved concurrency

    What it does
    Guarantees and caps a function
    Use it to
    Protect a database
  • Provisioned concurrency

    What it does
    Keeps environments ready
    Use it to
    Remove cold starts

2 / 2

  • SnapStart

    What it does
    Starts from a saved snapshot
    Use it to
    Cut cold starts in Java
Four settings that tune speed and concurrency.

是什么

Memory is the main performance setting. It runs from 128 MB to 10,240 MB, and CPU grows with it. At 1,769 MB a function has the power of one vCPU. A CPU-bound function often runs faster at a higher setting, and may cost about the same because it runs for less time. The timeout is set per function. The current documented maximum is 30 minutes, and older material says 15. Longer work belongs on Fargate, AWS Batch or EC2. A synchronous call carries up to 6 MB.

是什么

The default is 1,000 concurrent executions per Region, shared by all functions. New accounts may start with a lower limit. AWS raises it as you use Lambda. Reserved concurrency guarantees capacity to one function and also caps it, which protects a database from too many connections. Provisioned concurrency keeps environments ready, which removes cold starts for user-facing paths, at extra cost. SnapStart starts from a saved snapshot to cut cold starts for supported runtimes such as Java.

是什么

Triggers call in three ways. Synchronous: the caller waits and handles errors. Asynchronous: Lambda queues the event and retries twice, then sends it to a destination or a dead-letter queue. Poll-based: Lambda reads batches from SQS, Kinesis or DynamoDB Streams. To reach private resources, attach the function to a VPC. It then needs a NAT gateway or VPC endpoints to reach the internet or AWS services. Layers share libraries across functions.

要记住

  • Memory 128 MB to 10,240 MB. CPU scales with it. About 1,769 MB is one vCPU.
  • Reserved concurrency guarantees and caps. Provisioned concurrency removes cold starts.
  • Default 1,000 concurrent executions per Region, shared by all functions. New accounts may start lower.
  • Sync: caller waits. Async: queued, retried twice, then destination or DLQ. Poll-based: batches.

要记住

  • In a VPC, a function needs NAT or endpoints to reach the internet or AWS services.
  • Payload limits: 6 MB for sync calls, 1 MB for async.

考试中

  • “Function is slow and CPU-bound” points to more memory.
  • “Remove cold start latency for a user-facing API” points to provisioned concurrency.
  • “Protect a database from too many connections” points to reserved concurrency.
  • “Keep failed async events for later” points to an on-failure destination or a dead-letter queue.
  • “Job runs longer than the time limit” points to Fargate or AWS Batch.