A recreation registration API keeps shopping-cart selections only in server memory on one instance; scaling out drops carts mid-checkout. What change best aligns with a stateless compute pattern?
Select an answer to reveal the explanation.
Short Explanation
Leaving the cart only in one server's head is like keeping a sticky note on one clerk's monitor — hire a second clerk and the note is gone. Park the cart in a shared store or cache so any instance can pick it up. That is what "stateless compute" really means here.
Full Explanation
A recreation registration API that keeps shopping-cart selections only in server memory on one instance violates the stateless compute pattern the moment you scale out—new instances have empty memory, so carts vanish mid-checkout. The correct change is to externalize cart state to a shared data store or cache (DynamoDB or ElastiCache, for example) so any healthy instance can resume the citizen’s checkout. Stateless compute means request handlers bring authorization and load durable session/cart data from outside the process, enabling auto scaling, rolling deploys, and replacement of unhealthy hosts without losing municipal commerce state.
Pinning every shopper to one instance with sticky sessions and never adding capacity papers over the design flaw while creating a hotspot and deploy fragility. Increasing RAM so in-memory carts survive longer between deployments still leaves carts stranded on one host and lost on crash or scale-in. Duplicating the same in-memory map onto every new instance without a shared store does not synchronize carts; it multiplies inconsistent copies.
Exam caveat: “stateless” does not mean “no state anywhere.” It means application servers do not rely on local exclusive memory for conversational state. Cookies or JWTs may carry identifiers while DynamoDB holds the cart lines.
Operational check: move cart payloads to a shared store keyed by cart or citizen session ID; confirm two instances can alternate requests without empty carts; load-test scale-out during registration peaks; and set TTLs so abandoned carts do not grow forever.