How to ensure session persistence during EC2 failure?

A developer is designing a fault-tolerant environment where client sessions will be saved. How can the developer ensure that no sessions are lost if an Amazon EC2 instance fails?

  1. Use sticky sessions with an Elastic Load Balancer target group.
  2. Use Amazon SQS to save session data.
  3. Use Amazon DynamoDB to perform scalable session handling. Source Reference Answer
  4. Use Elastic Load Balancer connection draining to stop sending requests to failing instances.

Community Votes

C
100%

100% of anonymous learners picked answer C. Votes are pick records left by other test-takers — they are not the verified answer.

Community Insight

This question tests the ability to decouple application state from compute resources, with the common trap being confusing sticky sessions (session persistence) with actual data durability.

To prevent session loss during EC2 failures, developers must decouple session data from the instance. The community consensus confirms that Amazon DynamoDB provides the necessary scalability and fault tolerance for session handling.

Choosing Sticky Sessions (Option A) is a common mistake because, while it routes traffic to the same instance, it does not prevent data loss if that specific instance fails.

Community Discussion (3 comments)

KennethNg923 👍 3 Selected: C
Sticky sessions ensure that all requests from a particular client are sent to the same EC2 instance. While this can be useful for maintaining session state, it doesn't protect against data loss if an instance fails. If the instance holding a client's session fails, that session data would be lost. C is Correct: Use Amazon DynamoDB to perform scalable session handling. If an EC2 instance fails, the session data stored in DynamoDB remains intact and can be accessed by other instances.
lpennington 👍 1
A : Sticky sessions — also known as session persistence — is the method that makes it possible for the load balancer to identify requests coming from the same client and to always send those requests to the same server.
rdiaz 👍 2 Selected: C
C is the best of the options provided

Comments & Corrections

No comments yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

Submitted for moderation before publishing. Keep it helpful and respectful.

Expert Analysis

Why the Answer Is Correct

Amazon DynamoDB is a managed NoSQL database that offers high availability and durability across multiple Availability Zones. By storing session data in DynamoDB, the data persists independently of the EC2 instance lifecycle. If an instance fails, a new instance can retrieve the session data from DynamoDB without any loss.

Why the Other Options Are Wrong

Sticky sessions (Option A) bind a user to one instance; if that instance dies, the session dies. Amazon SQS (Option B) is designed for message queuing between services, not for real-time session state retrieval. Connection draining (Option D) only ensures in-flight requests complete before an instance terminates; it does not save session state.

Community Comment Notes

Comment [1] highlights the critical flaw in sticky sessions regarding data loss. Comment [3] reinforces the definition of sticky sessions, helping clarify why it is insufficient for fault tolerance. The community unanimously supports DynamoDB as the robust solution for scalable session handling.

Official Reference

Exam Strategy

When questions ask about fault tolerance or data loss prevention regarding sessions, immediately look for options that decouple state from compute. Avoid sticky sessions unless the question specifically asks about maintaining context without requiring persistence across failures.

Related Analysis

Practice All DVA-C02 Questions

Access 100 questions with complete answers and detailed explanations.

View Full DVA-C02 Practice Test →

← Back to DVA-C02 Study Guide