Jeff’s Note #
Unlike generic exam dumps, ADH analyzes this scenario through the lens of a Real-World Lead Developer.
For DVA-C02 candidates, the confusion often lies in choosing between ephemeral local storage and persistent external storage for Lambda. In production, this is about knowing exactly how Lambda’s execution environment manages /tmp storage within the invocation lifecycle. Let’s drill down.
The Certification Drill (Simulated Question) #
Scenario #
An innovative fintech startup called “Moneta Solutions” is developing a serverless processing Lambda function. During each invocation, the function needs to create and modify temporary files up to 10 MB in size. These files are only needed transiently while the function runs and do not need to be retained after completion. The development team wants the most efficient and secure place to store these temporary files during invocation.
The Requirement: #
Where is the most appropriate location for storing these temporary files given the constraints?
The Options #
- A) The /tmp directory inside the Lambda execution environment
- B) Amazon Elastic File System (Amazon EFS)
- C) Amazon Elastic Block Store (Amazon EBS)
- D) Amazon Simple Storage Service (Amazon S3)
Google adsense #
leave a comment:
Correct Answer #
A) The /tmp directory inside the Lambda execution environment
Quick Insight: The Developer Imperative #
Lambda functions provide a built-in ephemeral file system mounted at /tmp that offers up to 512 MB of writable space, accessible during each invocation lifecycle. This is ideal for temporary files needed only during invocation and is faster and simpler than external storage options.
Content Locked: The Expert Analysis #
You’ve identified the answer. But do you know the implementation details that separate a Junior from a Senior?
The Expert’s Analysis #
Correct Answer #
Option A: The /tmp directory inside the Lambda execution environment
The Winning Logic #
AWS Lambda provides an ephemeral file system mounted at /tmp with up to 512 MB of storage capacity. This space is writable and persists only during the lifecycle of the invocation environment, making it ideal for temporary files created and accessed multiple times during a single invocation.
- Advantages include very low latency file access, no additional configuration or cost, and automatic cleanup across invocation environments.
- The
/tmpdirectory satisfies the exact requirement: files are temporary, <10MB, exist only during invocation, and require fast local access.
The Trap (Distractor Analysis) #
-
Why not B - Amazon EFS?
EFS provides persistent network file storage, ideal if files must persist across invocations or be shared across Lambda instances. However, its latency and cost are unjustified when files are short-lived and ephemeral. EFS setup also adds complexity and cold start overhead. -
Why not C - Amazon EBS?
EBS volumes cannot be attached to Lambda functions, only EC2 instances and certain containers. Also, this is a block storage service not natively integrated with Lambda. -
Why not D - Amazon S3?
S3 is object storage optimized for durability and persistence, not low-latency, multiple-write file operations within an invocation. Writing frequently changing temporary files to S3 would add latency and cost, and complicate cleanup logic.
The Technical Blueprint #
# Example: Writing a temporary file to /tmp in a Node.js Lambda function
const fs = require('fs');
const path = '/tmp/tempFile.txt';
exports.handler = async (event) => {
// Write a temporary file
fs.writeFileSync(path, 'Temporary data during invocation');
// Read or modify it multiple times here...
return `File written to ${path}`;
};
The Comparative Analysis #
| Option | API Complexity | Performance | Use Case |
|---|---|---|---|
| A) /tmp Directory | Minimal (local file I/O) | Very Low Latency (local ephemeral) | Temporary files during Lambda invocation |
| B) Amazon EFS | Moderate (mount, config) | Higher latency (network file system) | Persistent shared file storage across Lambdas |
| C) Amazon EBS | Not applicable | Not supported with Lambda | Attached block storage for EC2/containers |
| D) Amazon S3 | Moderate (SDK calls) | Higher latency, eventual consistency | Durable, persistent object storage |
Real-World Application (Practitioner Insight) #
Exam Rule #
“For the exam, always pick /tmp for ephemeral, transient file storage inside Lambda when dealing with files under 512 MB that don’t require persistence.”
Real World #
“In production, if your temp files exceed 512 MB or require sharing between invocations, consider EFS. For persistent archival or large objects, S3 is your go-to.”
(CTA) Stop Guessing, Start Mastering #
Disclaimer
This is a study note based on simulated scenarios for the AWS DVA-C02 exam.