Soru

Zorluk: OrtaServerless Development with AWS Lambda

A development team has configured a telemetry analysis application where an Amazon SQS queue triggers an AWS Lambda function to process device payloads. During load testing, the team observes the following issues:

1. Telemetry payloads are occasionally processed multiple times by different concurrent executions of the Lambda function.
2. The Lambda function periodically fails with a 'No space left on device' error when downloading temporary configuration files for validation.

Which two changes should the developer implement to resolve these issues? (Select TWO.)

  1. Configure the SQS queue's visibility timeout to be at least six times the timeout of the Lambda function.Cevap
  2. Modify the Lambda function code to delete the downloaded validation files from the /tmp directory before the handler execution completes.Cevap
  3. C
    Decrease the SQS queue's visibility timeout to match the Lambda function's timeout to guarantee that failed messages are immediately visible for reprocessing.
  4. D
    Place the Lambda function in a public subnet of the VPC and associate a public IP address to allow outbound HTTP connections for downloading files.
  5. E
    Increase the memory allocation of the Lambda function, which automatically increases the ephemeral disk space proportionally up to 10 GB.

Cevap

The correct options are configuring the SQS queue's visibility timeout to be at least six times the Lambda function's timeout, and deleting the validation files from the /tmp directory before the handler execution completes.
Configuring the SQS queue's visibility timeout to be at least six times the Lambda function's timeout prevents messages from being visible to other consumers while the active invocation is running, thereby resolving the duplicate processing issue. Additionally, explicitly deleting downloaded files from the /tmp directory before the execution finishes ensures that subsequent invocations reusing the execution context do not run out of space.

Adım Adım Çözüm

1
Analyze the cause of duplicate message processing in SQS-to-Lambda integrations.
Identify that if SQS visibility timeout is too close to or less than Lambda's execution timeout, messages can reappear in the queue before the Lambda function finishes processing, leading to duplicate invocations.
This establishes that the SQS queue's visibility timeout must be set to at least six times the Lambda function's timeout.
2
Analyze the cause of the 'No space left on device' error in Lambda executions.
Understand that because Lambda execution contexts are reused, files downloaded to the /tmp directory persist across subsequent invocations, eventually exhausting the storage limit.
This shows the need to clean up temporary files in the /tmp directory at the end of each handler execution.

Anahtar Kavram

AWS Lambda ephemeral storage lifecycle management and Amazon SQS integration timeout best practices.
Bu soruyu puanla