Cloud Architecture Design Principles and Trade-offs Questions
The cross-pillar reasoning skill for architecting cloud systems: weighing reliability, scalability, security, performance, and cost against each other to justify ONE architectural choice over another under real constraints (budget, team size, timeline, existing systems). Covers well-architected-style design reviews, resilience and failure-mode reasoning (blast radius, graceful degradation, idempotency), consistency-versus-availability trade-offs (CAP/PACELC), and scenario-based decisions such as choosing a managed versus self-hosted component or an architectural style (monolithic, microservices, or serverless) for one system. Provider-agnostic: no specific cloud vendor's service catalog. This topic is the JUSTIFICATION layer, not a subsystem deep dive: a full design of observability, disaster recovery, identity and access management, networking, caching, or Kubernetes orchestration belongs to that subsystem's own topic. Comparing compute abstractions (VM versus container versus serverless versus GPU/TPU) belongs to compute options and trade-offs. Choosing an architectural style is covered here, but the internal implementation patterns of that style (service mesh, sagas, two-phase commit, event sourcing) belong to microservices architecture and service design. Multi-year roadmaps, vendor evaluation, and governance belong to infrastructure strategy and technology selection. Spanning multiple cloud providers or bridging on-premises and cloud belongs to multi-cloud and hybrid cloud architecture. The IaaS/PaaS/SaaS delivery-model taxonomy belongs to cloud service and deployment models. Region-crossing replication and failover design belongs to multi-region and geo-distributed systems.
An enterprise relies on heavy Postgres extensions and custom operational tooling. Evaluate a managed relational database service versus self-managed Postgres on IaaS or Kubernetes. Walk through operational overhead, high availability, patching and backups, extension support, performance tuning, compliance, and total cost of ownership over a 3-year horizon, and give decision criteria for when each option wins.
Sample Answer
Direct answer
With heavy Postgres extensions and custom operational tooling already in place, the question is not whether managed is simpler in the abstract, it is whether the managed service actually supports every extension already depended on. If it does, managed usually wins on total cost of ownership (TCO) once operational labor is counted; if even one required extension is not supported, that alone can force self-managed regardless of the TCO math.
Structured elaboration
Decision dimensions
| Dimension | Managed relational database | Self-managed Postgres (IaaS, infrastructure as a service, or Kubernetes) |
|---|---|---|
| Operational effort | Provider handles patching, backups, failover | Team owns all of it, an ongoing headcount cost |
| High availability, patching, backups | Built-in, usually with a service-level agreement | Team designs and tests failover, backup, and patch cadence itself |
| Extension support | Limited to the provider's allow-list, can be a hard blocker | Full control, any extension can be installed |
| Performance tuning | Some knobs exposed, deep kernel or storage-level tuning usually unavailable | Full control down to the host and storage layer |
| Compliance | Provider often holds relevant certifications you can inherit | Compliance evidence must be built and maintained in-house |
| Control over upgrades | Provider sets the upgrade cadence and window, usually with some scheduling control | Team chooses exactly when and to what version |
| Failure modes owned | Provider outages, provider-imposed limits, connection caps, maintenance windows | Every failure mode: disk full, replication lag, split-brain during failover, human error during a manual patch |
| Portability | Some managed services use proprietary replication or extensions that complicate migrating away | Fully portable, it is just Postgres |
| Scalability | Usually easier vertical resize and read-replica provisioning via a console or API | Team builds the read-replica and connection-pooling setup itself |
| TCO at 3 years | Higher unit price, but operational labor is bundled in | Lower unit price, only cheaper once labor is counted honestly |
A quantitative TCO method
For a 3-year horizon: TCO equals infrastructure cost times 36 months, plus operational labor hours per month times fully-loaded hourly cost times 36 months, plus expected incident cost, the probability of a serious incident times its average cost, over 3 years.
Worked with illustrative but internally consistent numbers: managed costs $1,200/month infrastructure, roughly 4 hours/month of team time, mostly monitoring and minor tuning, at a fully-loaded rate of $100/hour. TCO equals ($1,200 x 36) plus (4 x $100 x 36), equals $43,200 plus $14,400, equals $57,600 over 3 years, plus a small incident-cost term since the provider absorbs most operational failure modes. Self-managed costs $600/month infrastructure, cheaper raw compute and storage, but roughly 20 hours/month of operational time, patching, backup verification, tuning, on-call for database issues, at the same $100/hour rate, plus an estimated one serious incident over 3 years, a botched failover or a missed backup verification, costing an estimated $15,000 in downtime and recovery labor. TCO equals ($600 x 36) plus (20 x 100 x 36) plus $15,000, equals $21,600 plus $72,000 plus $15,000, equals $108,600 over 3 years.
In this worked scenario, self-managed's lower infrastructure line, $21,600 versus $43,200, is completely swamped by its operational labor line, $72,000 versus $14,400, making managed nearly half the 3-year TCO despite its higher sticker price. The crossover would move toward self-managed only if the team's operational hours per month were far lower, an already-expert dedicated database function running it as a small fraction of their time, or if infrastructure cost dominated at a scale where the managed markup per unit becomes very large.
Decision criteria for when each wins
- Managed wins when every required extension is supported, the team has no dedicated database operations depth, and the honest operational-hours estimate is more than a token amount per month.
- Self-managed wins when a required extension is genuinely unsupported by every viable managed option, a hard blocker rather than a preference, the team already has deep Postgres operations expertise as a sunk cost, so the labor line shrinks toward the managed team's numbers, or the scale is large enough that the managed markup, not the labor, is the dominant cost line.
Worked example
See the quantitative TCO comparison above: given the stated inputs, managed comes out at roughly $57,600 and self-managed at roughly $108,600 over 3 years, entirely because of how much the operational-labor line dominates once honestly estimated.
Trade-offs and pitfalls
- The most common mistake is comparing sticker prices only, $600 versus $1,200, and concluding self-managed is cheaper, without ever pricing the labor line honestly; the TCO method above exists specifically to force that number onto the page.
- Underestimating incident probability for self-managed is a second common mistake: a team that has never had an incident often means it has not been running long enough yet, not that the risk is zero.
- A hard extension requirement should be verified against the managed provider's current supported-extension list before ruling it out, not assumed from an old version of the documentation, since managed providers add extension support over time.
Explain eventual consistency, read-your-writes consistency, monotonic reads, and causal consistency. For each, give a concrete requirement where it would be the right guarantee to offer, and describe how you would support it in a cloud service through your choice of caching and replication strategy.
Sample Answer
Direct answer
These four guarantees are points on a spectrum of how fresh and ordered the data a reader sees has to be. Eventual consistency only promises convergence once writes stop; read-your-writes guarantees a client sees its own writes; monotonic reads guarantees a client's view never goes backward in time; causal consistency guarantees that if one write causally depends on another (it read it, or the same actor made both), everyone sees them in that order, though unrelated concurrent writes can appear in any order. Pick the weakest guarantee that still satisfies the real requirement, because every guarantee above eventual consistency costs latency, availability, or both.
Structured elaboration
The four guarantees
| Guarantee | What it promises | What it does not promise |
|---|---|---|
| Eventual consistency | If writes stop, all replicas converge to the same value eventually | No bound on staleness while writes continue, no ordering guarantee between reads |
| Read-your-writes | A client always sees writes it made itself, on its next read | Nothing about seeing other clients' writes promptly |
| Monotonic reads | A client's successive reads never go backward, never see an older value after a newer one | Nothing about seeing the very latest write quickly |
| Causal consistency | Writes that are causally related (B read A, or the same client wrote both) are seen by everyone in that order | Concurrent, unrelated writes can be seen in different orders by different clients |
Where each is right, and how to implement it
- Eventual consistency fits a "like count" or view counter on a social post: nobody notices if it is off by a few seconds. Implement with asynchronous replication and a cache with a short time-to-live (TTL), reads hitting the nearest replica or cache with no coordination.
- Read-your-writes fits a shopping cart: a customer adds an item and must see it on the very next page load, but does not need to see someone else's cart changes instantly. Implement by routing a client's reads to the same replica or region that handled their last write (sticky routing, or a read-after-write token the client passes back), or by writing through a cache synchronously for that client's session.
- Monotonic reads fits an account balance shown across several pages in one session: a user should never see a balance regress from $100 to $80 back to $100 as they navigate, even before any new transaction happens, because replica lag could otherwise expose an older value after a newer one. Implement with a session-bound read version (a logical timestamp or vector clock, a small per-write counter set that lets a node detect which operations causally precede which), routing reads only to a replica that has caught up to at least that version.
- Causal consistency fits a comment thread or a bank transfer's downstream notifications: if a bank debits account A and credits account B, and a fraud check reads B's new balance to decide whether to hold funds, that check must see the credit; two unrelated customers' unrelated transfers can be seen in any order relative to each other. Implement by propagating a causal token (a vector clock or dependency list) with each write and having replicas withhold delivery of a write until its dependencies have already been applied locally.
Applied to a machine learning feature store and model metadata
A feature store serving a model at inference time typically only needs eventual consistency for feature values themselves: a slightly stale feature rarely changes a prediction meaningfully, and the alternative, blocking inference on cross-region replication, would blow the latency budget. Model metadata, such as which model version is currently active or what its rollback target is, needs a stronger guarantee than the features: a rollback decision made by one operator must be immediately visible to every serving node, which is read-your-writes at minimum and often causal consistency if the rollback event has dependencies, such as rolling back the model and the feature schema together. This is a case where two data classes inside the same system legitimately sit at different points on the spectrum.
Worked example
Account A has $500. A transfer service debits A by $200 and credits B by $200. If a support dashboard reads B's balance right after the transfer and the read lands on a stale replica, it might show B's pre-credit balance: an eventual-consistency gap that would be embarrassing but not incorrect, because the transfer log stays the source of truth. If instead a downstream automated fraud check reads B's balance to decide whether $200 looks anomalous for that account, and it must evaluate the post-credit state to be correct, causal consistency is required: the fraud check's read is causally dependent on the credit write, so the system must guarantee it sees that write, by routing the check to a replica the write has already reached, verified via a causal token, or by having the check read from the same node that processed the write.
Trade-offs and pitfalls
- Reaching for the strongest guarantee "to be safe" is the most common mistake: causal or read-your-writes consistency usually requires sticky routing or coordination that adds latency and reduces how freely the system can load-balance or fail over.
- Monotonic reads and read-your-writes are easy to conflate: read-your-writes is about your own writes, monotonic reads is about time never going backward regardless of who wrote it. A system can offer one without the other.
- A subtle pitfall is implementing causal consistency with a coarse dependency tracker, such as "same user ID" as a proxy for causality: it over-serializes unrelated writes from the same user and under-serializes genuinely causal writes across users, like the transfer-then-fraud-check example above, so dependency tracking has to be based on actual read-then-write chains, not identity.
Explain the difference between strong consistency, causal consistency, and eventual consistency. A game leaderboard needs to serve reads with sub-millisecond latency: which of these three consistency models would you choose for it, and why? Walk through the user-facing trade-offs of that choice.
Sample Answer
Strong consistency guarantees that every read reflects the latest completed write, as if there were only ever a single copy of the data. Causal consistency guarantees only that operations one client's actions causally depend on are seen in that order, while operations with no causal relationship to each other can appear in a different order to different readers. Eventual consistency guarantees only that, once writes stop arriving, every replica eventually converges on the same value, with no bound on how stale any individual read can be until then.
For a leaderboard that has to serve reads in under a millisecond, eventual consistency is the only one of the three that can meet the requirement. Strong and causal consistency both need the reader's request to check or coordinate with something beyond its own local copy of the data, and that coordination alone costs more time than a sub-millisecond budget allows, before any application logic runs at all. The design that follows is to keep the write path (the score submission itself) strongly consistent against one source of truth, so a score is never lost or double-counted, while serving every leaderboard read from a separate, eventually consistent, purely local cache.
Strong, causal, and eventual consistency compared
| Model | What every reader is guaranteed | What it costs to provide | Where it fits |
|---|---|---|---|
| Strong (linearizable) | Every read sees the single most recent committed write; all clients agree on one global order of operations | A quorum (a majority, more than half of replicas) must coordinate on the write, usually via a consensus protocol (an algorithm such as Raft or Paxos that gets multiple replicas to agree on one ordered log), and a read from a follower must confirm it is not stale | Bank balances, inventory counts, anything where a stale or out-of-order read is a correctness bug, not just an inconvenience |
| Causal | A reader who is causally connected to a write (made it, or read something derived from it) always sees it, and in order; unrelated concurrent writes can appear in different orders to different readers | Needs a way to track "happened before," such as vector clocks (a small per-write counter set that lets a node detect which operations causally precede which) or a session token, but not global agreement | Comment threads or activity feeds, where a reply must appear after the comment it replies to, but the exact order of two unrelated users' actions does not matter |
| Eventual | Every replica converges to the same value once writes stop, with no guaranteed order or freshness bound while writes are still happening | The cheapest of the three: a read is served from whichever local copy is nearest, with zero cross-node coordination at read time | Anything where a bounded staleness window is acceptable and raw read speed matters more than a strict ordering guarantee, which is exactly the leaderboard case here |
Why a sub-millisecond budget decides this before anything else does
It is worth putting an actual number on what "coordination costs time" means. Light in optical fiber travels at roughly two-thirds its vacuum speed, because of the fiber's refractive index (about 1.5):
vfiber=nc≈1.53×108 m/s=2×108 m/sA round trip has to cover the distance out and back, so for a full latency budget of one millisecond (0.001 s), the farthest a single round trip can physically reach is:
d=2vfiber×tbudget=22×108 m/s×0.001 s=1×105 m=100 kmThat is the physical floor, before adding any serialization, queueing, or protocol overhead, and before accounting for the fact that both strong and causal consistency typically need more than one such round trip (a consensus protocol commits a write only once a quorum acknowledges it, and a linearizable read from a follower has to separately confirm it is not stale). Availability zones, the isolated data-center groups a cloud region is built from, are frequently already tens of kilometers apart, and a cross-region hop is hundreds to thousands of kilometers. Any read that must coordinate beyond its own local node is competing for a budget that a single physical hop can already exhaust on its own. A read that never leaves a local, in-memory cache pays none of this cost: its latency is bounded only by local compute and local network, which is routinely and comfortably under a millisecond.
The leaderboard architecture: split the write path from the read path
flowchart LR
subgraph WRITE["Write path (authoritative, strongly consistent)"]
P[Player submits score] --> W[Game service]
W --> DB[(Primary score store: atomic max-update)]
end
subgraph READ["Read path (eventual, sub-millisecond)"]
C[(In-memory sorted leaderboard cache)]
R[Leaderboard read request] --> C
C --> UI[Rendered rank list]
end
DB -. async fan-out on bounded refresh interval .-> C
The write path is where correctness lives, so it stays strongly consistent: a score submission is an atomic "set my score to X only if X beats what is stored" update against a single primary store, which stops two near-simultaneous submissions (including a cheating client racing its own requests) from corrupting the record. The read path is where the latency requirement lives, so it is eventually consistent: an asynchronous process fans the primary store's changes out to a precomputed, sorted, in-memory structure on a bounded refresh interval, and every leaderboard read is served from that local structure with no coordination at read time. This is the same idea as CQRS (Command Query Responsibility Segregation: separating the path that accepts writes from the path that serves reads so each can be optimized on its own terms), applied specifically along the consistency dimension.
User-facing trade-offs of choosing eventual consistency for reads
- A player who just posted a new high score may not see their own updated rank until the next refresh cycle runs, because their read is served from the same eventually consistent cache as everyone else's. This is the specific cost of applying eventual consistency uniformly: it breaks the one guarantee a user notices immediately, seeing the result of their own action. It is usually patched at the interface layer rather than the consistency layer: show the player's own new score optimistically the instant the write is acknowledged, while the shared leaderboard view around them stays eventually consistent.
- Two players can briefly see different top-ten lists, or different ranks for the same third player, depending on which cache replica or edge location served each of them. For a leaderboard this is usually an acceptable cost, since a rank is inherently a snapshot in time, but it has to be a deliberate call. If the actual requirement were "every player sees an identical ranking at every instant," that pushes back toward strong consistency and a completely different latency conversation.
- Anti-cheat or audit tooling must never read from the eventually consistent cache to decide something consequential, such as banning a player or voiding a score, because that data is stale or momentarily wrong by design. It should read from the strongly consistent primary store, which is exactly why the two paths were split apart in the first place instead of trying to make one path serve both needs.
- The refresh interval feeding the cache needs an explicit staleness bound, a service-level objective (SLO) such as "the cache is never more than a few hundred milliseconds behind the primary store," plus monitoring against that bound, rather than just running "as fast as the background job happens to go." An eventually consistent system with no stated limit on how eventual is not a design decision, it is an outage waiting to be noticed.
- The most common wrong turn here is reaching for strong consistency "to be safe" on the read path, which is precisely where the stated requirement (latency) lives, while the operation that genuinely needs a strong guarantee, the write, gains nothing extra from that choice. Matching the consistency model to the specific operation, instead of applying one model uniformly across the whole feature, is the actual skill this question is testing.
You must propose an MVP architecture for a client when non-functional requirements like throughput, high availability, and data residency are unknown. Given a 3-month timeline and constrained budget, describe a pragmatic architecture approach, how you'd isolate unknowns, what managed services you'd favor, and a clear migration path to an enterprise-grade solution.
Sample Answer
Direct answer
When throughput, high availability, and data residency are unknown, the right move is not to guess at numbers, it is to buy optionality: build on managed, horizontally-friendly primitives that are cheap to run small and do not require a rewrite to run big, and explicitly defer the decisions you lack information for rather than baking a guess into the architecture.
Structured elaboration
Isolating the unknowns
List each unknown non-functional requirement and attach a cheap, reversible default plus a trigger for revisiting it:
- Throughput unknown: default to a small compute tier behind a load balancer, or a serverless/function-as-a-service (FaaS) tier that scales to near-zero, with autoscaling on from day one so "how much traffic" never requires an architecture change, only a scale-out.
- High-availability requirement unknown: default to single-region, multi-availability-zone (deploy across at least two isolated data-center locations within one region) rather than single-instance, because that is a small cost delta that buys real resilience. Defer multi-region until a contract or service-level agreement (SLA) actually requires it.
- Data residency unknown: default to a region you are confident is acceptable for the client's most likely jurisdiction, and choose a database and storage layer that supports regional migration or replication later without a schema rewrite.
Pragmatic architecture approach
- Favor managed services over self-hosted infrastructure for everything that is not the product's core differentiator: managed database, managed object storage, managed authentication. This buys speed now and defers the "should we self-host this" decision until real usage data exists to justify it.
- Keep the compute tier stateless from day one, even before knowing if you need to scale out, because retrofitting statelessness later is far more expensive than building it in when the codebase is small.
- Instrument observability, metrics, logs, and basic tracing from the start. This is how the unknowns get resolved: after a few weeks of real usage there will be real throughput numbers, real latency numbers, and real answers to where users actually are.
Migration path to enterprise-grade
Define concrete, metric-based triggers rather than a calendar date: if p95 (95th-percentile) latency exceeds the service-level objective (SLO) for two weeks running, move the database to a larger tier or add a read replica; if a customer contract requires 99.95 percent uptime, add multi-availability-zone failover automation and a documented recovery time objective; if a customer requires data to stay in a specific country, add regional data partitioning before onboarding them. This turns unknown non-functional requirements from a blocker into a backlog with entry criteria, so the MVP architecture is never wrong, only intentionally incomplete.
Worked example
A 3-month, fixed-budget MVP for a B2B scheduling tool with no committed customers yet chooses: a managed relational database, single region, one primary with automated backups; a stateless API tier on a managed container or serverless platform with autoscaling enabled; managed object storage for file uploads; and a managed authentication service instead of building auth. The unknowns are tracked as three backlog items: add multi-region if a customer requires it, add a read replica if p95 database latency exceeds 150ms, add multi-availability-zone failover if a signed contract requires an uptime SLA above what single-zone typically delivers. None of these require re-architecting the application layer when triggered, because the compute tier was already stateless and the database already supports read replicas and regional failover as an upgrade, not a rewrite.
flowchart LR
subgraph MVP["MVP, month 0 to 3"]
A[Stateless API tier, autoscaling] --> B[(Managed DB, single region)]
A --> C[(Managed object storage)]
A --> D[Managed auth]
end
MVP -->|"trigger: p95 latency SLO breach"| E[Add read replica]
MVP -->|"trigger: signed SLA requiring HA"| F[Add multi-AZ failover]
MVP -->|"trigger: contract requires data locality"| G[Add regional partitioning]
Trade-offs and pitfalls
- The main risk of deferring everything is deferring something that is actually cheap to build in now and expensive to retrofit, statelessness being the classic example. The discipline is to defer numbers, how much throughput, how available, but not defer structural choices, like statelessness, that are cheap now and costly later.
- Choosing a database or storage layer that looks cheap now but hard-binds you to one region's proprietary replication format is a common trap: it turns "add data residency later" into a full migration rather than a configuration change.
- A pragmatic MVP architecture can look under-engineered to a stakeholder expecting "enterprise-grade" on day one. Presenting the trigger-based backlog explicitly makes the gaps look intentional and monitored rather than accidental.
Explain the difference between stateless and stateful application design in cloud environments. Cover how each approach affects horizontal scaling, fault tolerance, and autoscaling behavior; typical ways to externalize state (databases, distributed caches, sticky sessions) and their trade-offs; and practical examples of when you would choose a stateful service over a stateless design for a large-scale cloud system.
Sample Answer
Direct answer
A stateless application instance keeps no client-specific data in its own memory or local disk between requests, so any instance can handle any request; a stateful instance holds onto data, an in-progress session, an open connection, cached per-client state, that only exists on that specific instance. Stateless design is what makes horizontal scaling and autoscaling simple and safe; stateful design is sometimes unavoidable, a database, a real-time connection, and needs its own replication and failover strategy instead of relying on interchangeability across instances.
Structured elaboration
Effect on horizontal scaling, fault tolerance, and autoscaling
- Stateless: any request can go to any instance, so a load balancer can distribute freely, new instances can join and immediately start serving traffic with zero warm-up state, and autoscaling can add or remove instances at will without worrying about what data lives where. If an instance crashes, its in-flight requests fail and should be retried against a different, equally-capable instance, but no unique data is lost, since none was uniquely held there.
- Stateful: a request often has to go back to the same instance that holds its state, session affinity, or "sticky sessions," which limits how freely a load balancer can distribute load and complicates autoscaling, since removing an instance means either migrating or losing whatever state it held. If a stateful instance crashes, whatever it held that was not replicated elsewhere is lost, so fault tolerance for stateful components depends entirely on the component's own replication design, not on the interchangeability that makes stateless fault tolerance simple.
Ways to externalize state, and their trade-offs
- Shared database: durable, works from any instance, but adds a network round trip and a shared dependency that has to scale with total request volume.
- Distributed cache, a shared in-memory store, not local process memory: fast, works from any instance, but usually has weaker durability guarantees than a database, acceptable for session data, not for anything that must never be lost.
- Sticky sessions, session affinity at the load balancer: keeps the simplicity of storing session state in local process memory while still allowing multiple instances, but reintroduces the stateful instance's core weakness, if that specific instance dies, that session's data is gone, and autoscaling down can silently drop active sessions when their instance is removed from rotation.
- Signed client-side tokens, a JSON Web Token (JWT), a compact signed token the client holds and sends with each request: eliminates server-side session storage entirely, since the token itself carries the session data, verifiably signed so the server can trust it without a lookup, but a single token cannot be cheaply revoked before it expires, revocation requires extra infrastructure like a denylist, and putting too much data in the token bloats every request.
When to choose a stateful service anyway
Some components are inherently stateful and there is no honest way to make them stateless: a database itself, a real-time collaborative-editing session holding an in-memory document state, or a long-lived connection coordinating a multiplayer game session. For these, the right response is not to force statelessness onto them, it is to give the stateful component its own replication and failover design, data replicated to a standby, automatic failover with a bounded data-loss window, rather than relying on the "any instance can serve any request" property that stateless components get for free.
Failover testing and backup/replication for stateful components
Because a stateful component's fault tolerance depends entirely on its own replication design, that design needs to be tested directly, not assumed: run regular failover drills, deliberately killing the primary and confirming a replica takes over within the expected time and with the expected, bounded data loss, and verify backups are actually restorable, not just that a backup job completed successfully, since a backup that silently corrupts on write is only discovered at restore time if nobody ever tests the restore path.
A concrete sticky-session-to-stateless conversion
Before: a web application stores each logged-in user's session, their user ID and a few permission flags, in local process memory, and the load balancer uses sticky sessions, routing based on a cookie, to always send that user back to the same instance. This works until that instance needs to be replaced during a deploy or an autoscale-down, at which point every user stuck to it is silently logged out. After: the session data, deliberately kept small, is moved into a signed JWT the client holds and sends with every request; the server verifies the signature and reads the data directly from the token, with no server-side lookup and no per-instance affinity needed at all. The load balancer can now distribute purely on load, any instance can serve any request, and removing an instance during a deploy or autoscale-down affects zero active sessions, because no session data lived on that instance in the first place.
Worked example
Before the conversion, a fleet of 10 instances holding sticky sessions loses roughly one-tenth of active sessions, whichever users happened to be stuck to that one instance, every time a single instance is cycled. A rolling deploy does not stop at replacing one instance, though: to actually ship the new code it works through all 10 in turn, so over the course of one full rolling deploy essentially the entire fleet's concurrent sessions get logged out at some point, roughly 10,000 forced re-logins at 10,000 average concurrent sessions, not just the 1,000 tied to any single instance. At 3 deploys a week that is roughly 30,000 forced re-logins a week, an order of magnitude worse than counting only one instance's share would suggest, purely as a side effect of deploy cadence. After moving to signed tokens, that number drops to zero, because a rolling deploy no longer intersects with where session data lives at all.
Trade-offs and pitfalls
- Moving too much data into a client-side token to avoid a server lookup can bloat every request and, more seriously, means that data cannot be instantly updated or revoked, a permission change does not take effect until the token expires and is reissued, so tokens work best for small, slowly-changing data, not as a general-purpose session store.
- A common mistake is treating "we're stateless now" as true because the web tier lost its local session state, while ignoring that the database or cache behind it is still a single point of failure with no tested failover; statelessness at the app tier does not remove the need for a real replication and failover design at the data tier.
- Skipping failover drills for stateful components because "the replication is configured, it should just work" is the most common way a real failover event turns into a longer-than-expected outage: configuration that has never been exercised under a real failure is a hypothesis, not a verified capability.
Unlock Full Question Bank
Get access to all 22 Cloud Architecture Design Principles and Trade-offs interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.