DVA-C02 Troubleshooting and Optimization Practice Question
A developer is optimizing a Node.js Lambda function that processes CSV files from S3. The function reads the entire file into memory, processes it, and writes results to DynamoDB. For large files, the function runs out of memory. What is the MOST effective optimization?
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Use the AWS SDK's S3 GetObject with a stream and process in chunks.
Using the AWS SDK's S3 GetObject with a stream allows the function to process the CSV file in chunks, avoiding loading the entire file into memory. This directly addresses the memory issue for large files. Option A is incorrect because increasing timeout does not reduce memory usage. Option B is incorrect because while increasing memory might help, it does not solve the root cause and may increase costs; streaming is more efficient. Option D is incorrect because S3 Select is used to filter columns from S3 objects using SQL, but it does not solve the problem of loading the entire file into memory; it could reduce the data transferred but the function still needs to handle streaming or chunking.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Increase the Lambda timeout to allow more processing time.
Why it's wrong here
Increasing the Lambda timeout only extends the maximum execution duration, not the available memory. An 'out of memory' error indicates that the function exhausted its allocated RAM *before* the timeout was reached, meaning more time would not resolve the fundamental resource constraint. This action would not prevent the Node.js process from attempting to load the entire large CSV file into memory, leading to the same memory exhaustion issue.
- ✗
Increase the Lambda function memory to 3008 MB.
Why it's wrong here
Increasing memory to 3008 MB might allow the function to handle larger files, but it does not fix the inefficiency of loading the entire file into memory. Streaming is a more effective optimization that avoids high memory usage.
- ✓
Use the AWS SDK's S3 GetObject with a stream and process in chunks.
Why this is correct
Using the AWS SDK's S3 GetObject with a stream allows the Node.js Lambda function to read the large CSV file incrementally, rather than loading the entire object into memory at once. By processing data in small, manageable chunks as it arrives, the function significantly reduces its peak memory footprint. This approach directly addresses memory exhaustion by avoiding the need to hold the entire file in RAM, making it highly efficient for large file processing.
- ✗
Use S3 Select to retrieve only necessary columns.
Why it's wrong here
S3 Select is used to retrieve only specific columns from S3 objects using SQL queries, which reduces data transfer but still requires the function to load the entire file into memory unless combined with streaming. It does not directly address the memory issue.
Quick reference
AWS S3 Storage Class Comparison
| Storage Class | Min Duration | Retrieval | Use Case |
|---|---|---|---|
| S3 Standard | None | Immediate | Frequently accessed data |
| S3 Standard-IA | 30 days | Immediate | Infrequent access, rapid retrieval |
| S3 One Zone-IA | 30 days | Immediate | Non-critical infrequent data |
| S3 Intelligent-Tiering | None | Immediate–hours | Unknown or changing access patterns |
| S3 Glacier Instant | 90 days | Milliseconds | Archive with instant retrieval |
| S3 Glacier Flexible | 90 days | Minutes–hours | Archive, flexible retrieval |
| S3 Glacier Deep Archive | 180 days | Hours | Long-term compliance archive |
Go deeper
Related to this question
About these practice questions
This DVA-C02 question is part of Courseiva's 724-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This DVA-C02 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DVA-C02 exam.