Soru

Zorluk: OrtaDebugging Lambda Execution and Configuration Issues

A developer is troubleshooting a Python-based AWS Lambda function that processes real-time telemetry packets from an Amazon Kinesis Data Stream. The function is configured with a memory limit of 128 MB128\text{ MB} and a timeout of 3 seconds3\text{ seconds}. It is attached to a private subnet within a VPC to query an Amazon RDS database. During testing, the developer observes the following issues:
- The Lambda function logs `Task timed out after 3.00 seconds` when processing batches with larger telemetry packets.
- The Lambda function fails with a socket timeout error when trying to send analytical summaries to an external third-party API.

Which two actions should the developer take to resolve these issues? (Select two.)

  1. Configure a NAT Gateway in a public subnet of the VPC, and add a route in the private subnet's route table pointing 0.0.0.0/00.0.0.0/0 traffic to the NAT Gateway.Cevap
  2. Increase the Lambda function's timeout configuration to allow more processing time and allocate more memory to scale CPU performance proportionally.Cevap
  3. C
    Associate the Lambda function with a public subnet and enable the public IP assignment configuration on the function's elastic network interface (ENI).
  4. D
    Add a route in the private subnet's route table that maps all internet-bound traffic (0.0.0.0/00.0.0.0/0) directly to an Internet Gateway.
  5. E
    Modify the Lambda function's initialization code to force the destruction of the execution context at the end of every handler invocation.

Cevap

To resolve these issues, the developer must configure a NAT Gateway in a public subnet and update the private subnet's route table to route internet-bound traffic to it, and also increase the Lambda function's timeout and memory configuration.
To resolve the external API connection issue, the Lambda function must have outbound internet access. Since the function is in a private subnet, a NAT Gateway must be created in a public subnet, and the private subnet's route table must route all outbound traffic (0.0.0.0/00.0.0.0/0) to this NAT Gateway. To resolve the timeout issues, the function's execution time must be extended by increasing the timeout configuration, and allocating more memory will scale the CPU performance proportionally, allowing it to process large telemetry packets faster.

Adım Adım Çözüm

1
Diagnose the database and external API connectivity failure.
The Lambda function is associated with a private subnet to securely query the Amazon RDS database, which blocks direct access to the public internet.
A Lambda function configured to run in a VPC does not have access to the public internet by default, resulting in socket timeouts when attempting to reach the external third-party API.
2
Configure outbound internet connectivity.
Create a NAT Gateway in a public subnet of the VPC and add a route in the private subnet's route table pointing 0.0.0.0/00.0.0.0/0 traffic to the NAT Gateway.
The NAT Gateway translates private IP traffic from the private subnet to a public IP and routes it to the Internet Gateway, enabling the Lambda function to reach the external API.
3
Resolve the execution timeout issue.
Increase the Lambda function's timeout setting and allocate more memory.
Larger telemetry packets require more processing time and compute power. Increasing the memory limit scales the CPU proportionally, and extending the timeout window prevents premature execution failures.

Anahtar Kavram

Configuring VPC Lambda network routing for internet access and tuning memory and timeout settings to resolve processing bottlenecks.
Tahmini Süre:2m 0s
Bu soruyu puanla