AWS Certified Developer – Associate (DVA-C02)Development with AWS ServicesEasy

A developer is building a serverless application that uses AWS Lambda functions to process user requests. The application needs to store temporary, per-request data that can be accessed by subsequent invocations of the same Lambda function instance within a short period. The data does not need to persist beyond the lifetime of a single function instance or between different instances. Which AWS service is the MOST cost-effective and performant solution for storing this temporary data?

  1. AAmazon ElastiCache for Redis
  2. BLambda's /tmp directory
  3. CAmazon DynamoDB
  4. DAmazon S3
Show answer & explanation

Correct answer: B. Lambda's /tmp directory

Lambda functions provide a local /tmp directory that can be used for temporary storage during the execution of a function instance. This is the most cost-effective and performant solution for temporary, per-invocation data that does not need to persist.

Why the other options are wrong

  • A. ElastiCache is an in-memory cache, which is performant but adds significant cost and operational overhead for simple temporary file storage within a single Lambda instance.
  • C. DynamoDB is a persistent database and is overkill for temporary, per-invocation data storage, incurring higher costs and latency.
  • D. S3 is object storage and is not suitable for high-performance, temporary file system-like access within a Lambda execution, and incurs storage and request costs.

Lambda /tmp Directory

A local, ephemeral storage space (up to 512 MB) available to AWS Lambda functions for temporary files during an invocation. Data is lost after the invocation or instance termination.

  • Ephemeral storage for Lambda functions.
  • Up to 512 MB of disk space.
  • Data is lost between invocations or instance restarts.
  • Ideal for temporary files, processing artifacts, or small caches.

Memory trick: Lambda's 'temp' folder is for fleeting thoughts.

More Development with AWS Services questions