SAP-C02 Continuous Improvement for Existing Solutions Practice Question
A company is running a stateful web application on EC2 instances in an Auto Scaling group behind an ALB. The application stores session data locally on the instance. The company notices that users are frequently logged out and lose session data during scaling events. What is the MOST operationally efficient way to preserve session state?
⚠ Common exam trap
Candidates often choose sticky sessions (Option D) thinking it solves session persistence, but they overlook that sticky sessions only route traffic to the same instance and do not protect against data loss when that instance is terminated during scaling events.
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 data to ElastiCache for Redis and modify the application to use it.
Migrating session state to ElastiCache for Redis provides a centralized, external, and highly available session store that persists independently of EC2 instance lifecycles. This ensures that when instances are terminated or added during Auto Scaling events, session data remains intact and accessible from any instance, eliminating user logouts and data loss. It is operationally efficient as it requires minimal application code changes and leverages a fully managed, in-memory data store optimized for low-latency access.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Migrate session data to ElastiCache for Redis and modify the application to use it.
Why this is correct
ElastiCache for Redis externalises session state into a shared, highly available store, so any instance in the Auto Scaling group can serve any user after scaling events. This removes instance-local dependency without custom replication logic, making it the most operationally efficient fix.
- ✗
Create a custom AMI that pre-populates session data from Amazon S3.
Why it's wrong here
A custom AMI bakes a static snapshot at launch; sessions created afterwards remain instance-local and are lost on termination, and stale data is served. It is tempting because AMIs standardise instance configuration, which suits immutable deployment patterns, not dynamic session storage.
- ✗
Increase the Auto Scaling group's cooldown period to 600 seconds.
Why it's wrong here
Cooldown only delays subsequent scaling actions; it neither externalises session state nor prevents instance termination from discarding locally held sessions. It is tempting because it reduces scaling churn, which suits workloads where brief thrashing, not session loss, is the concern.
- ✗
Enable sticky sessions (session affinity) on the ALB.
Why it's wrong here
Sticky sessions bind a user to one instance, so that instance's termination during scale-in still destroys the local session data. It is tempting because affinity preserves continuity while instances remain healthy, suiting stateless tiers where only routing consistency matters.
Go deeper
Related to this question
About these practice questions
Courseiva writes every SAP-C02 question from scratch — 984 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
Same concept, more angles
1 more way this is tested on SAP-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 is running a stateful web application on EC2 instances in an Auto Scaling group. Users report that their sessions are lost when instances are terminated during scale-in. What should a solutions architect do to preserve session state?
medium- A.Use lifecycle hooks to save session data to Amazon S3 before instance termination.
- B.Enable sticky sessions (session affinity) on the Application Load Balancer.
- ✓ C.Store session state in Amazon ElastiCache.
- D.Increase the Auto Scaling group's cooldown period to prevent rapid scaling.
Why C: ElastiCache provides a centralized, fast session store that persists across instance terminations, ensuring session state is retained even when instances are scaled in. Option A is wrong because using lifecycle hooks to save session data to Amazon S3 is unreliable due to the high latency and the risk that the termination process may not complete the save in time. Option B is wrong because sticky sessions (session affinity) on the Application Load Balancer can cause uneven load distribution and still result in session loss if all instances in a target group are replaced or if the specific instance with the session is terminated. Option D is wrong because increasing the Auto Scaling group's cooldown period only delays the next scaling activity but does not preserve session state when instances are eventually terminated.
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This SAP-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 SAP-C02 exam.