Courseiva
Resilient Cloud Solutions →mediumMultiple Choice

Externalizing Session State for Stateless Architecture

A company runs a critical web application on EC2 instances behind an Application Load Balancer. The application stores session state in an in-memory cache on each instance. During deployment of a new version, users experience session timeouts and errors. Which design change will MOST effectively improve resilience and avoid session loss during deployments?

Quick Answer

The correct choice is migrating session state to ElastiCache for Redis, because it decouples session data from individual EC2 instances by externalizing session state for stateless architecture. This design change ensures that when instances are replaced during a deployment, the centralized Redis cluster persists all session data independently, preventing timeouts and errors that occur when in-memory caches are destroyed. On the AWS Certified DevOps Engineer Professional DOP-C02 exam, this scenario tests your understanding of stateless application patterns and the trade-offs between instance-local storage versus externalized state stores; a common trap is assuming sticky sessions or instance health checks alone solve the problem, but they do not survive instance termination. Remember the memory tip: “Redis lives on, even when EC2 is gone”—if your session state is externalized, your users won’t be logged out during rolling updates.

⚠ Common exam trap

Watch out — candidates often confuse sticky sessions (which only route traffic consistently) with session persistence (which requires external storage), leading them to choose option A despite it not preserving session data across instance replacements.

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

✓

Migrate session state to ElastiCache for Redis.

Migrating session state from in-memory EC2 instance storage to ElastiCache for Redis decouples session data from individual instances. This ensures that when a new deployment replaces instances, sessions persist independently, preventing timeouts and errors. ElastiCache provides a centralized, highly available session store that survives instance termination and scaling events.

Answer analysis

Option-by-option breakdown

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

  • ✗

    Enable sticky sessions (session affinity) on the ALB.

    Why it's wrong here

    Sticky sessions pin a client to one instance, so when that instance is replaced during deployment the pinned session is still lost, and draining merely delays the failure. It is tempting because affinity does prevent cross-instance cache misses during normal operation, but it cannot survive instance replacement.

  • ✓

    Migrate session state to ElastiCache for Redis.

    Why this is correct

    ElastiCache for Redis externalises session state from individual instance memory, so any instance behind the Application Load Balancer can serve any request. This removes the constraint that deployments destroy in-memory sessions, preventing timeouts and errors as instances are replaced.

  • ✗

    Increase the ALB idle timeout to 600 seconds.

    Why it's wrong here

    Raising the ALB idle timeout only extends how long an idle connection may persist; it does nothing when the target instance is replaced and its in-memory cache vanishes. It is tempting because idle timeouts genuinely cause dropped long-lived connections, but the stem's session loss stems from instance-local state, not premature connection closure.

  • ✗

    Increase the EC2 instance size to handle higher memory.

    Why it's wrong here

    More memory on each instance cannot preserve session state when that instance is terminated during deployment; the cache dies with the host. It is tempting because memory pressure does cause cache eviction, so resizing helps when sessions are evicted under load, not when instances are replaced.

About these practice questions

One of 1,298 original DOP-C02 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Same concept, more angles

2 more ways this is tested on DOP-C02

These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.

Variation 1. A company runs a critical web application on EC2 instances behind an Application Load Balancer (ALB). The application stores session state in an Amazon DynamoDB table. During a recent traffic spike, users experienced session timeouts and the application became unavailable. Which design change would BEST improve resilience?

medium
  • ✓ A.Move session state to Amazon ElastiCache for Redis with cluster mode disabled.
  • B.Enable DynamoDB global tables or use a Multi-AZ deployment for the table.
  • C.Add a read replica to the DynamoDB table.
  • D.Increase the EC2 instance sizes to handle more traffic.

Why A: Moving session state to ElastiCache for Redis offloads read/write operations from DynamoDB during traffic spikes, reducing the risk of throttling and session timeouts. While cluster mode disabled means a single node, it provides in-memory caching that improves performance and can be scaled up to handle increased load, making the application more resilient compared to relying solely on DynamoDB for session state during spikes. Option B is incorrect because DynamoDB is inherently multi-AZ, and global tables are for multi-region deployments, not for handling traffic spikes or throttling. Option C (adding a read replica) does not address write bottlenecks or session persistence. Option D (increasing EC2 instance sizes) does not resolve the session state storage issue.

Variation 2. A company runs a stateful web application on EC2 instances behind an ALB. The application stores session data in memory. The company wants to make the application stateless to improve resilience. Which TWO changes should the company make?

medium
  • A.Increase the instance memory to store more sessions
  • ✓ B.Disable sticky sessions on the ALB
  • C.Enable sticky sessions (session affinity) on the ALB
  • ✓ D.Store session data in Amazon ElastiCache for Redis
  • E.Use an NLB instead of an ALB

Why B: To make the application stateless, the company should disable sticky sessions on the ALB (option B) and store session data in Amazon ElastiCache for Redis (option D). Disabling sticky sessions ensures that requests can be routed to any instance, and storing session data externally removes the dependency on in-memory state on individual instances, improving resilience. Option A is incorrect because increasing instance memory does not solve the statefulness issue. Option C is incorrect because enabling sticky sessions would maintain state on instances. Option E is incorrect because using an NLB does not address session state management.

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This DOP-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 DOP-C02 exam.