Courseiva
Question 1,161 of 724
Development with AWS ServiceshardMultiple ChoiceObjective-mapped

DVA-C02 DynamoDB Practice Question

A developer is building a real-time chat application using WebSockets via API Gateway. The backend uses AWS Lambda functions to handle connect, disconnect, and message events. The application needs to broadcast messages to all connected clients. What is the most scalable and cost-effective way to maintain the list of connection IDs and broadcast messages?

⚠ Common exam trap

Candidates often think that in-memory storage (option C) is sufficient for Lambda functions, but Lambda instances are ephemeral and stateless; connection IDs must be stored in a persistent, shared data store like DynamoDB.

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

Store connection IDs in a DynamoDB table. Use a Lambda function to query all connection IDs and send messages using the API Gateway Management API.

DynamoDB provides a scalable and cost-effective solution for storing connection IDs because it is a NoSQL database designed for high availability and low latency. The Lambda function can query the entire table to retrieve all connection IDs and then use the API Gateway Management API (via `postToConnection`) to send messages to each client. This approach scales horizontally because multiple Lambda instances can access the same DynamoDB table. Option A is wrong because SQS FIFO queues are not suitable for broadcasting all messages to all connections; they are designed for point-to-point messaging and would require polling, adding latency and cost. Option C is wrong because an in-memory list in a single Lambda instance does not persist across cold starts and cannot be shared across multiple concurrent Lambda instances, leading to data loss and incorrect broadcasts. Option D is wrong because ElastiCache Redis adds operational complexity and cost, and using its Pub/Sub feature would require additional infrastructure; DynamoDB is simpler and more aligned with serverless best practices.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Use an SQS FIFO queue to store connection IDs and have a Lambda function poll the queue to broadcast.

    Why it's wrong here

    Using an SQS FIFO queue to store connection IDs is unsuitable for broadcasting in a real-time chat application. SQS FIFO queues are designed for strict message ordering and exactly-once processing of individual messages, not for maintaining a live, queryable list of broadcast targets. A Lambda function polling the queue would process each connection ID sequentially, introducing significant latency and complexity, as the queue's design does not facilitate retrieving all active connections simultaneously for a broadcast operation.

  • Store connection IDs in a DynamoDB table. Use a Lambda function to query all connection IDs and send messages using the API Gateway Management API.

    Why this is correct

    Storing connection IDs in a DynamoDB table is the robust and scalable solution for managing WebSocket connections with API Gateway. DynamoDB provides a highly available, low-latency, and persistent store for these IDs. When a message needs to be broadcast, a Lambda function can efficiently query the DynamoDB table to retrieve all active connection IDs. It then uses the API Gateway Management API's `PostToConnection` action to send the message to each client, ensuring reliable and scalable real-time communication.

  • Maintain an in-memory list of connection IDs in a global variable of a single Lambda function.

    Why it's wrong here

    Maintaining an in-memory list of connection IDs in a global variable of a single Lambda function is fundamentally flawed for a scalable real-time application. AWS Lambda functions are stateless and ephemeral; their execution environments are frequently recycled or new instances are provisioned for concurrent requests. Any data stored in-memory is lost between invocations and not shared across multiple function instances, leading to an incomplete and inconsistent list of active connections and preventing reliable message broadcasting to all users.

  • Use Amazon ElastiCache Redis to store connection IDs and use Redis Pub/Sub for broadcasting.

    Why it's wrong here

    ElastiCache Redis with Pub/Sub is unsuitable because it broadcasts messages *internally* to subscribed backend services, not directly to external WebSocket clients managed by API Gateway. Lambda functions would still need to retrieve connection IDs and individually invoke API Gateway's `PostToConnection` API for each client. This option is tempting as Redis Pub/Sub is a highly effective, low-latency mechanism for inter-service communication or distributing events *between different backend application instances*.

Quick reference

Cloud Service Model Comparison

ModelYou ManageProvider ManagesExamples
IaaSOS, runtime, apps, dataHardware, hypervisor, networkingEC2, Azure VMs, GCP Compute Engine
PaaSApps and dataOS, runtime, middleware, hardwareElastic Beanstalk, Azure App Service
SaaSData and settings onlyEverything elseMicrosoft 365, Salesforce, Workday
FaaS / ServerlessFunction code onlyInfra, scaling, runtimeLambda, Azure Functions, Cloud Run
CaaSContainers and appsKubernetes, OS, hardwareEKS, AKS, GKE

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Last reviewed: Jun 20, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

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.