Courseiva
Continuous Improvement for Existing SolutionshardMultiple ChoiceObjective-mapped

Perform Rolling Updates Without Losing Session State

A company runs a stateful application on EC2 instances in an Auto Scaling group behind an ALB. They want to perform a rolling update without losing session state. Which solution is most appropriate?

Quick Answer

The answer is to enable sticky sessions (session affinity) on the ALB and perform a rolling update. This works because sticky sessions bind a user’s session to a specific EC2 instance via a cookie, ensuring that during the gradual replacement of instances, each client continues hitting the same healthy instance that holds their in-memory state. On the AWS Certified Solutions Architect Professional SAP-C02 exam, this scenario tests your understanding of how to maintain session state during infrastructure changes, often appearing as a trap where candidates incorrectly choose blue/green deployments or simple scale-out strategies. The key trap is that blue/green deployments can lose state unless you also replicate session data externally, while terminating instances immediately or scaling out without affinity will route requests to instances lacking the session. Remember the mnemonic: “Stick with Sticky” for stateful rolling updates.

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

Enable sticky sessions (session affinity) on the ALB and perform a rolling update.

Enabling sticky sessions (session affinity) on the ALB ensures that requests from a user are consistently routed to the same instance during the rolling update, preserving session state. Option B (blue/green deployment) would require external session state management or state replication. Option C (scale out then scale in) may route new requests to instances lacking state, and Option D (terminate instances one by one) loses the state when the instance is terminated.

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 and perform a rolling update.

    Why this is correct

    Sticky sessions keep users on the same instance during transition.

  • Use a blue/green deployment with a new Auto Scaling group.

    Why it's wrong here

    State is lost unless externalized.

  • Scale out the Auto Scaling group, then scale in the old instances.

    Why it's wrong here

    Without sticky sessions, new instances may not receive the state.

  • Terminate instances one by one and let Auto Scaling replace them.

    Why it's wrong here

    Termination loses state.

About these practice questions

One of 1,660 original SAP-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

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 runs a stateful web application on EC2 instances in an Auto Scaling group. The application uses a shared file system mounted on each instance. The company wants to minimize downtime during deployments. What should they use?

medium
  • A.Use an in-place update without any hooks.
  • B.Use a rolling update with a lifecycle hook to gracefully handle connections and unmount the file system before instance termination.
  • C.Perform a blue/green deployment.
  • D.Terminate all instances and launch new ones.

Why B: A rolling update with a lifecycle hook (Option B) is the best approach for minimizing downtime in a stateful web application using a shared file system. The lifecycle hook allows the instance to gracefully handle existing connections and unmount the file system before termination, ensuring no data corruption or abrupt disconnection. This reduces downtime compared to other methods. Option A (in-place update without hooks) risks disrupting active connections. Option C (blue/green deployment) may not work seamlessly with stateful applications due to shared storage. Option D (terminate all instances) causes full downtime.

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.