Summary#
Every design decision buys something and pays for it with something else. There is no "best" database, protocol or architecture. There is only the option whose costs you can afford for the requirements you actually have.
The same trade-offs come up again and again:
- consistency vs availability, and its everyday form, strong vs eventual consistency;
- latency vs throughput;
- push vs pull;
- synchronous vs asynchronous communication;
- stateful vs stateless services;
- batch vs stream processing;
- normalization vs denormalization;
- read-optimised vs write-optimised storage;
- long polling vs WebSockets;
- concurrency vs parallelism;
- cost vs performance;
- build vs buy;
- smaller ones such as REST vs RPC, read-through vs write-through caching, and vertical vs horizontal scaling.
For each, you should know what each side gives you, what it costs, the signals in the requirements that point one way or the other, and the numbers that make the cost concrete.
Presenting a trade-off well is a skill of its own:
- Name the options.
- Tie the decision to a specific requirement.
- State what you gain and what you give up, with numbers.
- Say how you would mitigate the downside.
- Say what would make you change your mind.
Why It Exists#
Requirements pull in different directions. Users want answers instantly, the business wants every payment correct, finance wants the cloud bill lower, and the team wants something they can operate at 3 a.m. Physics and economics add hard limits:
- light takes ~70 ms to cross the Atlantic and back;
- a disk can do only so many random reads per second;
- RAM costs far more per gigabyte than object storage;
- every extra service is another thing to deploy, monitor and page someone for.
A design that maximises one property almost always sacrifices another. Engineers who know the recurring trade-offs can do three things that separate good design from guesswork:
- predict the weak points of a design before building it;
- explain why they chose what they chose, which matters in design reviews and interviews;
- change course cheaply when requirements change, because they know which decision depended on which requirement.
In interviews, trade-off reasoning is the main thing separating senior candidates from junior ones. Almost any reasonable architecture can pass. What interviewers listen for is whether you know why you picked it, what it costs, and when you would pick something else. This page builds on CAP Theorem and PACELC, the most famous trade-off of all.
How It Works#
The sections below cover each trade-off in the same shape:
- the two options, explained simply;
- what each gains and costs, with numbers;
- the requirement signals that should push you to one side;
- real examples, and the hybrid that many production systems end up with.
Few real systems pick one pure side. The mature answer is usually "A for this part, B for that part, because of these requirements".
Consistency vs availability#
The trade-off. When data is replicated and the network between replicas fails (a partition), each request must either:
- wait or fail until the system can confirm the latest data (consistency), or
- answer immediately with whatever local data exists, possibly stale (availability).
You cannot have both during a partition. That is the CAP theorem.
What each side costs.
- Choosing consistency means some users see errors or timeouts during network problems. Even in normal times, writes wait for confirmations from other replicas.
- Choosing availability means users may see old data, and if both sides of a partition accept writes, the system must merge conflicting versions later.
Signals that point to consistency:
- money moves (payments, balances, refunds);
- a scarce resource is allocated (seat 14C, the last pair of shoes, a username, a meeting room);
- an action is irreversible once taken (sending a wire transfer, shipping an order);
- the system coordinates other systems (locks, leader election, configuration).
Signals that point to availability:
- content is consumed rather than acted on (feeds, profiles, product pages, reviews);
- the data is naturally approximate (view counts, likes, "people also bought");
- an error is worse than slightly old data ("show the menu from 10 minutes ago rather than no menu");
- users are global and latency matters more than recency.
Concrete example. Consider a concert ticketing system.
- The seat map that 100,000 fans are refreshing can be a few seconds stale. If it is down, fans panic and refresh even harder, so availability wins there.
- The moment someone clicks "buy seat 14C", the reservation must be strongly consistent. One authoritative record decides who gets the seat, and if the database cannot be reached, the right answer is "please try again", not "you have the seat" given to two people.
Hybrid in practice. Strong consistency for the small, critical write path; availability and caching for the large, read-heavy browse path. The browse path is often 99% of the traffic, and the critical path is often under 1%, so you pay the cost of consistency only where it matters.
Strong vs eventual consistency#
This is the same tension in everyday terms, even with no partition in sight.
- Strong consistency means every read sees the most recent write. After a user changes their password, every server rejects the old one immediately.
- Eventual consistency means replicas catch up "soon", typically within milliseconds to seconds, and until then reads may return old values.
Why eventual is so common. Keeping replicas in lock-step costs round trips on every write, or on every read, or both.
| Setup | Strong write latency | Eventual write latency |
|---|---|---|
| Replicas in one data center | ~1-2 ms (quorum ack) | ~0.5 ms (local commit) |
| Replicas across zones in one region | ~2-5 ms | ~0.5-1 ms |
| Replicas across continents | ~70-150 ms | ~1 ms local, replicated in the background |
At 10,000 writes per second, a 100 ms cross-region confirmation also means about 1,000 requests are always in flight waiting (Little's law: 10,000/s × 0.1 s). That costs memory, connections and threads.
What eventual consistency costs you. The application must tolerate anomalies:
- a user edits their bio, refreshes, and sees the old one;
- a comment count says 12, but only 11 comments load;
- two replicas accept conflicting edits, and one must win.
Most of these can be hidden cheaply with session guarantees:
- read-your-writes: send a user's reads to the primary for a few seconds after they write;
- monotonic reads: pin a user to one replica so they never see time go backwards.
Choosing. Ask: "If a user sees data that is two seconds old, what is the worst thing that happens?"
- If the answer is "they are mildly confused" or "nothing", choose eventual consistency, and add session guarantees for the user's own data.
- If the answer is "money is lost", "an item is oversold" or "a security change does not take effect", choose strong consistency for that operation.
A password change, a permission revoke and an account suspension are worth special mention. They look like profile edits, but they are security decisions. They need strong consistency, or at least immediate invalidation of sessions and caches. See Consistency Models for the full ladder between the two extremes.
Latency vs throughput#
Definitions.
- Latency is how long one request takes, measured from the user's point of view, ideally as percentiles (p50, p99).
- Throughput is how many requests the system completes per second.
They are related, but they are not opposites. Improving one often hurts the other.
Why they conflict:
- Batching raises throughput but adds latency. Writing 1,000 rows to a database in one batch is often 10-50x more efficient than 1,000 single inserts, because it costs one round trip and one fsync. But the first row waits for the batch to fill. Kafka producers expose this directly:
linger.ms = 0sends immediately;linger.ms = 10waits up to 10 ms to fill a batch, gaining throughput and compression and costing up to 10 ms of extra latency. - High utilisation raises throughput but explodes latency. In queueing terms, waiting time grows like
utilisation / (1 - utilisation). A server at 50% busy has short queues. At 90%, the waiting factor is 9. At 95%, it is 19. Running hot squeezes more throughput per dollar but makes tail latency spike, so latency-sensitive services usually run at 40-70% CPU. - Compression and encryption trade CPU time per request (latency) against bytes on the wire (network throughput).
- Strong durability. fsync on every write adds ~0.1-1 ms per write on SSD, or more on cloud disks. Group commit, which writes many transactions with one fsync, raises throughput at a small latency cost.
Signals.
- Latency first: user-facing interactive paths (search-as-you-type under 100 ms, checkout, game state), trading, ad bidding (where responses must arrive within about 100 ms).
- Throughput first: analytics pipelines, log ingestion, backups, ML training data, email campaigns, video transcoding. Nobody cares whether one log line takes 2 seconds to land if a billion lines land per hour.
The Uber example. A ride-hailing system receives location pings from millions of drivers every few seconds, and riders expect a match within seconds. Scaling it shows how latency and throughput goals combine.
- Vertical scaling, buying a bigger server, is the weak answer. It is expensive, needs downtime to upgrade, has a hard ceiling, and leaves a single point of failure.
- Geo-sharding is the strong answer. Partition services, queues and databases by geographic region (city or cell), and add read replicas inside each shard for read throughput.
- Throughput grows by adding shards.
- Latency falls, because each rider's request is served by infrastructure physically close to them, holding only that region's drivers.
- Cross-shard queries are needed only for searches near a shard boundary, when a rider stands at the edge of two regions and nearby drivers may live in either. Those queries scatter-gather: they query both shards and merge the results. That is slower, but rare.
- The cost is operational: shards must be balanced (dense cities can be split into more shards), data must be replicated for failover, and assignment must be stable. Consistent hashing over region cells, or a directory service mapping cells to shards, solves this.
How to present it. Do not just say "low latency and high throughput". Give targets: "p99 under 200 ms for matching, 1 million location updates per second ingested; we batch updates per driver every 4 seconds, which favours throughput on the ingest path, and keep the matching read path unbatched, which favours latency."
Push vs pull#
The trade-off. Who starts the data transfer?
- In push, the producer sends data to consumers as soon as it exists. Examples: server-sent notifications, webhooks, fan-out-on-write feeds, CDN pre-warming, Kafka brokers pushing to some client libraries.
- In pull, consumers ask for data when they want it. Examples: polling an API, fan-out-on-read feeds, Kafka consumers fetching from brokers, Prometheus scraping metrics.
What push gains and costs.
- Gain: freshness. Data arrives the moment it is produced, and consumers do not waste requests asking "anything new?"
- Cost: the producer must know who the consumers are, keep connections or endpoints for them, handle slow or offline consumers (buffering, retries, back pressure), and may waste work pushing to consumers who never look.
What pull gains and costs.
- Gain: consumers control their own pace. A slow consumer just falls behind rather than being overwhelmed, the producer stays simple and stateless about consumers, and replay is natural ("fetch from offset 1,000 again").
- Cost: latency up to the polling interval, and wasted requests when nothing changed. Polling every 5 seconds from 1 million clients is 200,000 requests per second, mostly answering "no news".
The classic case: news feeds.
- Push (fan-out on write): when a user posts, write the post ID into each follower's precomputed feed. Reads are fast, a single lookup. But a celebrity with 50 million followers creates 50 million writes per post.
- Pull (fan-out on read): when a user opens their feed, fetch recent posts from everyone they follow and merge them. Writes are cheap, but reads are expensive: following 500 accounts means up to 500 lookups, merged under a latency budget.
- Hybrid, which large social networks have described using: push for normal accounts, pull for celebrity accounts, and merge both at read time.
Another example: monitoring. Prometheus pulls metrics from targets. Scraping makes it easy to notice a dead target (the scrape fails) and keeps targets simple. Push-based systems (StatsD, OpenTelemetry push to a collector) work better for short-lived jobs that may die before a scrape, and across firewalls where the collector cannot reach the targets.
Signals.
- Push when freshness matters and consumers are known and online: chat, notifications, live scores, trading ticks.
- Pull when consumers vary in speed, need replay, or are many and unpredictable: batch analytics, mobile apps that sleep, metrics scraping, and log-based streaming consumers.
- Hybrid: push a tiny "something changed" signal, then let the client pull the details. This is how many mobile push notifications work: the push wakes the app, and the app fetches the content over the API.
Synchronous vs asynchronous communication#
The trade-off.
- In synchronous calls, the caller sends a request and waits for the response before continuing: an HTTP call, a gRPC call, a database query.
- In asynchronous communication, the caller hands off the work (a message on a queue, an event on a stream) and continues. The result arrives later, or never comes back to the caller at all.
Synchronous gains and costs.
- Gains: simplicity. Request in, answer out, errors are immediate, and the control flow is easy to read and debug. The caller knows the outcome.
- Costs: coupling in time and failure. If the callee is slow, the caller is slow. If it is down, the caller fails. Latencies add up along a chain. Availabilities multiply too: five services in a chain, each 99.9% available, give about 99.5% overall. Threads and connections are held while waiting.
Asynchronous gains and costs.
- Gains:
- decoupling: the producer works even if consumers are down, because messages wait in the queue;
- load levelling: bursts fill the queue instead of overloading consumers;
- independent scaling: add workers when the queue grows;
- fan-out: one event, many consumers.
- Costs:
- more moving parts (a broker to run);
- eventual results: the user sees "processing" rather than "done";
- harder debugging, because traces span queues;
- duplicate and out-of-order messages, since most brokers deliver at least once, so consumers must be idempotent;
- no immediate error for the caller.
Signals.
- Synchronous when the user needs the result to continue: login, reading a page, checking the price, validating input.
- Asynchronous when the work is slow (video transcoding, report generation), unreliable (third-party APIs), bursty (flash sales), or has several independent consequences (send email, update analytics, notify warehouse).
A deep example: payments and asynchronous networks. Card payments look synchronous to the shopper: click "pay", see "success" a second later. But card networks, banks and payment processors are distributed systems you do not control, and their responses can be delayed, duplicated or lost. A payment system must stay financially correct anyway:
- Idempotency keys. Every payment request carries a unique key from the client or merchant. If the request is retried after a timeout, the system returns the result of the first attempt instead of charging twice. The key and the result are stored durably, with a unique constraint.
- An explicit state machine. A payment moves through states such as
created → pending → authorized → captured, orfailed,refundedandunknown. A transition happens only from an allowed state, often enforced with a conditional update (UPDATE ... SET status='captured' WHERE id=? AND status='authorized'). - Timeouts are not failures. If the call to the processor times out, the charge may or may not have happened. Marking it "failed" and letting the user retry could double-charge them. The correct state is unknown/pending, resolved later by querying the processor with the same idempotency key, or by waiting for its webhook.
- Webhooks and polling together. The processor reports final outcomes asynchronously via webhooks, which may arrive late, twice or out of order. Handlers must therefore be idempotent and must respect the state machine. A periodic job also polls the processor for payments stuck in
pending, in case a webhook never arrives. - Durable intent before side effects. Write "payment X is being attempted" to the database before calling the processor. If the service crashes mid-call, a recovery job finds the record and resolves it. The transactional outbox pattern stores the state change and the event to publish in one transaction, so downstream services (order fulfilment, email) are never told about a payment that was not recorded, and are never left out of one that was.
- Ledger and reconciliation. Record every money movement as an immutable, append-only, double-entry ledger entry: debits equal credits. Every day, compare your records with the processor's settlement files. Any mismatch (they charged and you have no record, or the reverse) is flagged and resolved. Reconciliation is the final safety net for every bug in the asynchronous flow.
The lesson generalises. When your synchronous-looking flow depends on an asynchronous outside world, model the uncertainty explicitly, with states, idempotency, retries and reconciliation, rather than pretending the call either worked or failed.
Hybrid in practice. Respond synchronously with an acknowledgement and a job or payment ID ("202 Accepted"). Do the heavy or uncertain work asynchronously, and let the client poll a status endpoint or receive a push when it finishes. See Message Queues and Pattern: Long-Running Tasks.
REST vs RPC#
A smaller trade-off in the same family is how synchronous APIs are shaped.
- REST models the API as resources (
/orders/123) manipulated with standard HTTP verbs (GET, POST, PUT, DELETE), usually with JSON. It works naturally with HTTP caching (GET responses can be cached by browsers and CDNs), proxies and tooling, is easy to explore with curl, and suits public APIs consumed by many unknown clients. - RPC (gRPC, Thrift, JSON-RPC) models the API as functions (
CreateOrder,GetDriverLocations). gRPC adds binary Protobuf encoding (smaller and faster to parse than JSON), HTTP/2 multiplexing, streaming in both directions, and generated, strongly typed clients in many languages.
| REST | RPC (gRPC) | |
|---|---|---|
| Mental model | Resources and verbs | Procedures |
| Payload | Usually JSON (text) | Protobuf (binary), often 3-10x smaller |
| Caching | Native HTTP caching for GET | Not cacheable by standard HTTP caches |
| Browser support | Native | Needs gRPC-Web or a gateway |
| Streaming | Limited (SSE, chunked) | Built-in client, server and bidirectional streams |
| Contract | OpenAPI (optional) | .proto schema (required), code generation |
| Fits | Public APIs, CRUD, web clients | Internal service-to-service calls, low latency, polyglot fleets |
A common hybrid is REST (or GraphQL) at the public edge, and gRPC between internal services. See API Styles.
Stateful vs stateless services#
The trade-off.
- A stateless service keeps no client-specific data between requests in its own memory. Everything it needs comes with the request (a token, a session ID) or from a shared store (a database, Redis). Any instance can serve any request.
- A stateful service keeps data in its own memory or on its own disk across requests: a game server holding a match's state, a WebSocket server holding open connections, a database node, a stream processor holding running aggregates.
Stateless gains and costs.
- Gains:
- scaling out is trivial: add instances behind a load balancer;
- failure is cheap: a dead instance loses nothing, and the load balancer routes around it;
- deploys are easy: replace instances one at a time;
- autoscaling works smoothly.
- Costs:
- every request must fetch its state from somewhere, adding a network hop (~0.5-1 ms to Redis, 1-10 ms to a database) and load on that store;
- the shared store becomes the thing that is hard to scale.
Stateful gains and costs.
- Gains: speed and efficiency. Data is already in memory (~100 ns instead of ~0.5 ms), there is no serialisation per request, and long-lived connections (WebSockets, game sessions) stay put.
- Costs:
- requests must be routed to the right instance, with sticky sessions or consistent hashing;
- losing an instance loses its state unless it is replicated or checkpointed;
- scaling out means moving state (rebalancing shards);
- deploys must drain connections or migrate state;
- uneven load, the "hot shard", is common.
Signals.
- Stateless for ordinary API and web tiers. This is the default: push state down into databases and caches built to handle it.
- Stateful where the state is large, hot and tightly bound to computation: real-time collaboration and gaming, chat connection gateways, stream processing (Flink keeps state locally and checkpoints it), caches and databases themselves.
Hybrid in practice. A stateless API tier in front of a few carefully designed stateful tiers: the database, the cache, the WebSocket gateway. Each stateful tier gets an explicit plan for routing, replication and rebalancing. See Scaling Up vs Scaling Out.
Batch vs stream processing#
The trade-off.
- Batch processing collects data over a period, then processes it all at once: a nightly job computing yesterday's revenue, an hourly job rebuilding a search index.
- Stream processing handles each event, or small windows of events, continuously as it arrives: fraud scoring on every card swipe, live dashboards, trending hashtags.
Batch gains and costs.
- Gains:
- simplicity: the data is complete and fixed when the job runs;
- easy reprocessing: rerun the job;
- very high throughput, because data is read sequentially in big chunks and resources can be cheap (spot instances, off-peak hours);
- mature tools: Spark, SQL warehouses, Hadoop MapReduce historically.
- Costs: latency equal to the batch interval plus the job runtime. A nightly job means insights up to 24+ hours old. A failed job delays everything after it.
Stream gains and costs.
- Gains: results in seconds or less, and the ability to react while it still matters: block the fraudulent transaction, alert on the outage, update the trending list.
- Costs:
- complexity: events arrive late and out of order, so you need event time vs processing time, windows and watermarks;
- state management and exactly-once processing are hard;
- reprocessing history requires replaying a log;
- always-on infrastructure (Kafka, Flink, Kafka Streams, Spark Structured Streaming) costs money even when traffic is low.
Worked example. An e-commerce site wants "revenue per product category".
- Finance needs exact daily totals for reporting. A nightly batch over the orders table, or a warehouse query, is perfect: complete, auditable, cheap.
- The operations team wants to see within a minute if checkout revenue suddenly drops, which is a sign of a broken payment integration. A stream job summing order events in 1-minute windows, alerting when a window falls 50% below the same minute last week, does that.
Same data, two latency requirements, two tools.
Architectures that combine them.
- Lambda architecture (Nathan Marz): run a batch layer for accurate, complete results and a speed layer for fast, approximate ones, and merge them at query time. The cost is two codebases computing the same logic.
- Kappa architecture (Jay Kreps, 2014): use only a stream processor over a replayable log. To recompute history, replay the log through a new version of the job. Simpler, if the streaming engine can handle the full-history replay.
Signals. Choose stream when the value of the result decays within minutes: fraud, alerting, personalisation, live counters, surge pricing. Choose batch when completeness and cost matter more than freshness: billing, payroll, ML training sets, compliance reports, backfills. See Batch and Stream Processing.
Normalization vs denormalization#
The trade-off. How many times is each fact stored?
- Normalization stores each fact exactly once and links data with keys. The user's name lives only in
users; posts referenceuser_id. Queries join tables to assemble results. - Denormalization copies data to where it is read. Each post row also stores
author_name, or a precomputed "feed" table holds everything a screen needs in one row.
Normalization gains and costs.
- Gains:
- write correctness and simplicity: an update changes one row, so there is no risk of copies disagreeing;
- less storage;
- flexible querying: new questions can be answered with new joins.
- Costs: reads need joins. On one machine with good indexes, joins are fast. At scale, with many tables, large fan-out or data spread over shards, they become the bottleneck. A join across shards may mean querying every shard.
Denormalization gains and costs.
- Gains: reads become single lookups. "Fetch everything for this screen with one key" is what makes key-value and wide-column stores (DynamoDB, Cassandra) fast at huge scale, and what makes caches effective.
- Costs:
- write amplification: changing the author's name means updating every copy, possibly millions;
- consistency risk: copies updated asynchronously may disagree for a while, and copies missed by a bug disagree forever;
- more storage;
- less flexible queries: each new access pattern may need a new copy.
Worked example. A blog platform shows post lists with author names.
- Normalized:
SELECT p.*, u.name FROM posts p JOIN users u ON u.id = p.user_id WHERE .... A user renames themselves, and every post shows the new name instantly. - Denormalized:
posts.author_nameis copied on write. Listing is one table scan with no join. But renaming a prolific author means updating 40,000 rows, usually done asynchronously by an event consumer, and some pages show the old name for a while.
If authors rename themselves rarely and post lists are read millions of times a day, denormalization may be worth it. If the platform shards posts by post_id and users by user_id, the join crosses shards on every read, and denormalization becomes nearly mandatory.
Signals.
- Normalize the system of record, especially for transactional data where correctness matters: orders, payments, inventory, accounts. Start here.
- Denormalize for read models: caches, search indexes, feed tables, materialized views, analytics tables, NoSQL access-pattern tables.
- Hybrid, the common answer: keep the normalized source of truth, and build denormalized read models from it with change data capture or events. Keep reconciliation jobs to catch drift. See Data Modeling.
Read-optimised vs write-optimised storage#
The trade-off. Storage engines and data layouts can make reads cheap or writes cheap, but rarely both.
Write-optimised designs:
- Log-structured merge trees (LSM trees), as in Cassandra, RocksDB, ScyllaDB and HBase. Writes go to an in-memory table and an append-only log, and are flushed to disk as sorted, immutable files. Writes are sequential and very fast. Reads may have to check several files, so the engine uses bloom filters and background compaction, which rewrites data repeatedly: write amplification of 10-30x is common.
- Append-only event logs (Kafka, event sourcing): writing is just appending.
- Few indexes: every index is extra work on every write.
Read-optimised designs:
- B-trees, as in PostgreSQL, MySQL InnoDB and most relational databases. Data stays sorted in place, so a lookup is a few page reads (3-4 levels for billions of rows). Writes update pages in place, with random I/O and page splits.
- Many secondary indexes, covering indexes and materialized views: reads get faster and writes get slower.
- Columnar storage (BigQuery, Snowflake, ClickHouse, Parquet files) makes analytical reads of a few columns over billions of rows extremely fast, but single-row updates are costly.
- Denormalized copies and caches, as above.
Worked numbers. A table with 5 secondary indexes makes every insert update 6 structures. If one structure update costs ~0.1 ms of I/O and CPU, an insert costs ~0.6 ms instead of ~0.1 ms, and peak insert throughput per node falls accordingly. Dropping two rarely used indexes might raise write throughput by a third. If those indexes serve a dashboard that runs twice a day, moving that query to a replica or the warehouse is the better trade.
Signals.
- Write-optimised: ingest-heavy workloads such as metrics, logs, IoT telemetry, messaging, clickstreams and activity events, where writes far exceed reads, or reads are mostly recent ranges.
- Read-optimised: read-heavy workloads such as product catalogues, user profiles and content sites (typically 10:1 to 100:1 reads to writes), and analytics.
- Hybrid: CQRS. Accept writes into a write-optimised model (a log or normalized tables), then project them into read-optimised models (search indexes, caches, columnar tables). See Storage Engines and Event Sourcing and CQRS.
Read-through vs write-through (and other caching choices)#
Caching strategies are a compact version of the read/write trade-off.
- Cache-aside (lazy loading): the application checks the cache, and on a miss reads the database and fills the cache. Only requested data is cached, and a cache failure is survivable. But the first read of each key is slow, and data can be stale until the TTL expires or the key is invalidated.
- Read-through: the same flow, but the cache layer loads from the database on a miss (a caching library or a managed cache with a loader). Application code is simpler. Behaviour is otherwise like cache-aside.
- Write-through: every write goes to the cache and the database synchronously. Reads are always fresh and hit immediately after a write, but every write pays both latencies, and the cache fills with data that may never be read.
- Write-back (write-behind): writes go to the cache and are flushed to the database later, in batches. Writes are very fast and the database load is low. But a cache crash before the flush loses data, so it suits only data you can afford to lose or rebuild (counters, analytics), or caches with their own durable log.
- Write-around: writes go straight to the database, and the cache fills only on reads. This avoids polluting the cache with write-once data such as logs and uploads.
| Strategy | Read latency | Write latency | Freshness | Risk |
|---|---|---|---|---|
| Cache-aside / read-through | Miss on first read | DB only | Stale until TTL or invalidation | Stampede on hot misses |
| Write-through | Always hit after write | Cache + DB | Fresh | Cache full of unread data |
| Write-back | Hit | Cache only (fast) | Fresh in cache | Data loss on cache failure |
| Write-around | Miss after write | DB only | Fresh on next fill | First read after write slow |
The usual default is cache-aside with delete-on-write invalidation and TTLs as a safety net. Add write-through for data that is read immediately after it is written, and write-back only for loss-tolerant counters. See Caching Strategies.
Long polling vs WebSockets (and friends)#
The problem. HTTP is request-response: the server cannot speak until the client asks. For real-time features (chat, notifications, live prices, collaborative editing), the server needs a way to send data when it happens. There are four common options.
- Short polling: the client asks every N seconds. Trivial to build, but it wastes requests, and the delay is up to N seconds. With 1 million clients polling every 5 s, that is 200,000 requests per second, mostly empty.
- Long polling: the client sends a request, and the server holds it open until there is data or a timeout (say 30 s). It then responds, and the client immediately sends the next request.
- Near-real-time delivery over plain HTTP, through every proxy and firewall, with no special infrastructure.
- Each message costs a full HTTP request/response cycle with headers.
- A burst of messages means a burst of reconnects.
- Servers hold many idle requests.
- Ordering and missed messages between polls need care, usually a "since cursor" on each poll.
- Server-Sent Events (SSE): one long-lived HTTP response through which the server streams text events. It is one-way (server to client), has built-in reconnection with a
Last-Event-IDheader to resume, and is simple to implement behind ordinary HTTP infrastructure. It is ideal for feeds, notifications, live scores and progress updates. - WebSockets: an HTTP request is upgraded to a persistent, full-duplex TCP connection. Either side can send small frames at any time with tiny overhead (a few bytes per frame).
- Gains: the lowest latency and overhead for frequent two-way messages (chat, multiplayer games, collaborative editing, trading UIs).
- Costs:
- stateful connections: each server holds thousands to hundreds of thousands of open sockets;
- load balancers must support long-lived connections;
- deploys must drain connections;
- you need a routing layer to find which server holds a user's connection, often a pub/sub backplane such as Redis pub/sub or Kafka;
- you must implement heartbeats, reconnection and resumption yourself;
- some corporate proxies interfere.
| Short polling | Long polling | SSE | WebSocket | |
|---|---|---|---|---|
| Direction | Client pulls | Client pulls (server holds) | Server to client | Both ways |
| Latency | Up to interval | Near real time | Near real time | Lowest |
| Overhead per message | Full request | Full request | Small | Tiny |
| Infrastructure | Plain HTTP | Plain HTTP | Plain HTTP (streaming) | Upgrade-aware LBs, stateful servers |
| Fits | Rare updates, simple | Moderate updates, legacy clients | Feeds, notifications, dashboards | Chat, games, collaboration |
Signals. Use SSE when only the server pushes. Use WebSockets when the client also sends frequently, and latency or overhead matters. Use long polling as a fallback, or when infrastructure cannot hold persistent connections. Use short polling for rare updates where a delay of a minute is fine. See Realtime Communication.
Concurrency vs parallelism#
Definitions. The two are often confused.
- Concurrency is about structure: dealing with many tasks at once by interleaving them. One cook can manage five dishes by switching between them while each simmers.
- Parallelism is about execution: doing many tasks literally at the same instant on multiple cores or machines. Five cooks each make one dish.
Why it matters in design. Different bottlenecks need different tools.
- I/O-bound work, waiting on networks, disks and databases, benefits from concurrency. A web server spending 95% of each request waiting for a database can handle thousands of requests on a few threads using async I/O (Node.js event loop, Go goroutines, Java virtual threads, Python asyncio). Each waiting request costs only a little memory, not a whole thread.
- CPU-bound work, such as image resizing, compression, encryption, ML inference and video encoding, benefits from parallelism. More cores or more machines. Concurrency alone does not help: interleaving two CPU-heavy tasks on one core just makes both slower.
Trade-offs and limits.
- Concurrency adds complexity: race conditions, deadlocks, and the need for locks, atomics or message passing. Async code can be harder to read and debug.
- Parallelism is limited by Amdahl's law. If 10% of a job is serial, then even infinite cores give at most a 10x speedup.
- Example: with 16 cores, speedup = 1 / (0.1 + 0.9/16) ≈ 6.4x, not 16x.
- Parallelism also costs coordination: splitting work, merging results, contention on shared data.
- Shared-nothing designs sidestep both problems. Partitioning data so each core or node owns its own slice, as Redis Cluster shards, ScyllaDB's shard-per-core design and Kafka partitions do, gives parallelism without locks, at the cost of cross-partition operations.
Worked example. A thumbnail service receives 2,000 uploads per second. Each needs ~5 ms to fetch the image from object storage (I/O) and ~40 ms of CPU to resize.
- The CPU work needs 2,000 × 0.04 s = 80 cores busy at all times. That is parallelism: about 120 cores at ~65% utilisation, perhaps fifteen 8-core workers.
- The I/O wait is handled by concurrency inside each worker: dozens of in-flight fetches per worker, overlapping with resize work.
Adding async I/O alone would not help this service, and neither would adding cores to a service that is waiting on the database.
Vertical vs horizontal scaling#
- Vertical scaling (scale up) means a bigger machine: more cores, RAM and faster disks.
- Gains: no code changes, no distributed-systems problems, and strong consistency stays easy. Today a single server can have hundreds of cores and terabytes of RAM.
- Costs: price grows faster than capacity at the high end; there is a hard ceiling; upgrades often need downtime; and one machine is a single point of failure.
- Horizontal scaling (scale out) means more machines.
- Gains: nearly unlimited capacity, fault tolerance through redundancy, and incremental growth with commodity hardware.
- Costs: everything becomes distributed. You need load balancing, data partitioning, replication, consistency trade-offs and network failures.
The pragmatic path:
- Scale up while it is cheap and simple.
- Make the application tier stateless so it can scale out easily.
- Scale the data tier out only when the numbers demand it, through read replicas first and sharding later.
The Uber example above shows why very large systems eventually must scale out: no single machine can hold global driver locations at the required update rate and latency. See Scaling Up vs Scaling Out.
Cost vs performance#
The trade-off. Almost any performance target can be met with enough money: more replicas, bigger caches, more regions, faster disks, reserved capacity for peaks. The question is whether the business value of the improvement exceeds its cost.
Where the money goes.
| Lever | Performance gain | Typical cost |
|---|---|---|
| More RAM / bigger cache | Fewer DB reads, lower latency | RAM is roughly 50-100x the price per GB of SSD and far more than object storage |
| More replicas | Read throughput, availability | Each replica is a full copy of compute and storage |
| Multi-region active-active | Lower latency for distant users, regional failover | Roughly 2x+ infrastructure, cross-region data transfer fees, much harder engineering |
| Over-provisioning for peaks | No slowdown during spikes | Idle capacity most of the day |
| Premium storage (provisioned IOPS) | Predictable disk latency | Several times the price of standard volumes |
| Lower-latency instance types, GPUs | Faster compute | Expensive per hour; wasteful if underused |
Worked example. A product page has a p99 latency of 400 ms, and a team proposes adding a cache cluster to bring it to 150 ms. The cluster costs about $4,000 per month.
- If internal experiments suggest a few hundred milliseconds of latency moves conversion by a fraction of a percent, and the page drives $2 million in monthly sales, a 0.5% improvement is worth $10,000 per month. That is a good trade.
- For an internal admin dashboard used by 20 people, the same cache is wasted money. Accept 400 ms.
Several large companies have published experiments linking latency to engagement or revenue. The exact sensitivity varies by product, so measure your own.
Ways to get performance cheaply before paying for it:
- Fix the queries first: missing indexes, N+1 query patterns and full-table scans often account for most latency. They cost an engineer-day, not a server.
- Cache what is hot, not everything: often 20% of keys serve 80% of reads.
- Use a CDN for static and cacheable content: it is cheaper than serving from origin and faster for users.
- Autoscale instead of provisioning for the peak around the clock. Use spot or preemptible instances for interruptible batch work, often at large discounts.
- Tier storage: hot data on SSD or in RAM, warm data on cheaper disks, cold data in object storage or archive tiers.
- Set an SLO and stop optimising once you meet it. Going from 99th-percentile 150 ms to 120 ms may cost as much as going from 400 ms to 150 ms, and matter far less.
Signals. Spend for performance on revenue-critical and user-facing hot paths, and in real-time products where latency is the product (games, trading, video calls). Save on internal tools, batch jobs, cold data and rarely used features.
Build vs buy#
The trade-off.
- Build: write and run it yourself, either from scratch or by operating open-source software on your own infrastructure.
- Buy: use a managed service or commercial product: a managed database, a cloud queue, Stripe for payments, Auth0/Okta for identity, Datadog for observability, Algolia or Elastic Cloud for search.
Buy gains and costs.
- Gains:
- time to market: weeks instead of months;
- someone else handles upgrades, security patches, backups, scaling and on-call;
- mature features and compliance (PCI DSS for payments, SOC 2) that would take years to build.
- Costs:
- price at scale: managed services often cost several times the raw infrastructure;
- vendor lock-in: proprietary APIs, data export difficulties, price increases;
- less control over performance tuning and the roadmap;
- limits you cannot change (rate limits, item sizes, regions);
- another external dependency in your availability chain.
Build gains and costs.
- Gains: full control, an exact fit to your needs, no vendor margin at large scale, and a potential competitive advantage when the component is your product.
- Costs:
- engineering time to build, which is usually underestimated;
- ongoing operational load, which is usually underestimated even more: on-call, upgrades, security, scaling, documentation and hiring people who know it;
- risk of reinventing known bugs.
A practical rule. Build what differentiates your business; buy or adopt what does not.
- A payments startup should not write its own database engine, but may build its own risk scoring.
- A video platform may build its own transcoding pipeline and CDN logic at huge scale, as Netflix built Open Connect, but should buy email delivery.
- Early-stage companies should almost always buy: the scarcest resource is engineering time, not money.
- Very large companies sometimes bring commodity services in-house once their scale makes the vendor margin larger than a dedicated team's cost. Dropbox's move of most storage from Amazon S3 to its own infrastructure (the "Magic Pocket" project) is a well-known example.
A worked cost comparison. Running Kafka yourself:
- Infrastructure: ~6 brokers at $500/month each = $3,000/month.
- People: a meaningful fraction of an engineer's time for operations, say a quarter of a $200,000/year engineer = ~$4,200/month.
- Total: ~$7,200/month.
A managed equivalent might cost $6,000-12,000/month at the same throughput. At this scale, managed is roughly a wash and saves the on-call burden. At 20x the throughput, infrastructure grows nearly linearly but the people cost does not, so self-hosting may save hundreds of thousands of dollars a year. That is why the answer changes with scale.
Signals. Buy for commodity capabilities, early stages, compliance-heavy areas and small teams. Build or self-host when the capability is core, the scale makes vendor pricing dominant, the requirements exceed vendor limits, or data residency rules forbid vendors.
Other trade-offs worth naming#
These appear on other pages in depth, but they follow the same reasoning:
- Monolith vs microservices. A monolith gives simple deployment, in-process calls and easy transactions. Microservices give independent deployment and scaling per team, at the cost of network calls, distributed data and much more operational work. Start with a well-structured monolith unless team size or scaling needs force a split. See Monolith vs Microservices.
- SQL vs NoSQL. Relational databases give flexible queries, joins and transactions. Many NoSQL stores give predictable scaling for known access patterns, flexible schemas and high write throughput, at the cost of query flexibility and often consistency. Default to SQL; choose NoSQL for a specific, proven reason. See SQL vs NoSQL.
- Accuracy vs speed or cost. Approximate answers from probabilistic structures (HyperLogLog for unique counts with ~1% error in kilobytes of memory, Count-Min sketches for top-K), sampling, or pre-aggregated rollups are often orders of magnitude cheaper than exact ones. See Probabilistic Data Structures.
- Simplicity vs flexibility. Every configuration option, plugin point and abstraction makes future change easier and the present harder to understand. Design for the requirements you have plus one plausible step, not for every imaginable future.
- Security vs convenience. Shorter token lifetimes, mandatory MFA and strict network policies reduce risk and add friction. Spend friction where the risk is highest: admin actions and payments.
How to present a trade-off#
A good trade-off statement is short, concrete and tied to requirements. Use five steps:
- Name the options: "We could precompute feeds on write or assemble them on read."
- Anchor to a requirement: "Reads are 100x more frequent than posts, and feed loads must be under 200 ms p99."
- State gains and costs, with numbers: "Precomputing makes a feed load one Redis read (~1 ms), but a user with 10 million followers would trigger 10 million writes per post."
- Mitigate the downside: "So we precompute for normal users and merge celebrity posts at read time; celebrity accounts are under 0.01% of users."
- Say what would change your mind: "If most traffic came from users following many celebrities, as on a news-aggregator-style product, we would shift toward read-time merging with heavier caching."
Phrases that signal good judgement:
- "Given requirement X, I'd choose A over B, accepting cost Y, which we mitigate with Z."
- "This is a two-way door, so I'll start simple and revisit when we pass N users or N requests per second."
- "Most of the system can be eventually consistent; only these two operations need strong consistency."
Anti-patterns:
- naming a technology without a reason ("we'll use Kafka" with no stated need for replay, fan-out or throughput);
- listing pros and cons without choosing;
- claiming an option has no downside;
- choosing based on fashion ("everyone uses microservices");
- optimising for a requirement nobody stated.
When to Use It#
- At every major decision point in a design: data store, consistency level, communication style, caching, processing model, deployment shape.
- In requirements discussions, to surface hidden priorities: "Would you rather show stale data or an error?" or "Is a 2-second delay acceptable for analytics?"
- In design reviews and architecture decision records, to make the reasoning reviewable and reversible.
- When a system is struggling, to find which earlier trade-off no longer fits the current scale.
When NOT to Use It#
- Do not turn every small choice into a debate. Libraries, formats and conventions with low cost of change can simply follow team defaults.
- Do not invent trade-offs to sound thorough. If one option clearly dominates for the stated requirements, say so and move on.
- Do not reopen settled decisions without new information: a changed requirement, a new measurement, or a new constraint.
How to Implement It#
- Write the requirements as numbers: latency targets, throughput, data size, consistency needs, availability target, budget, team size.
- List the decisions the design depends on, and for each, the realistic options (usually two or three).
- Score the options against the requirements that matter for that decision, not against every requirement.
- Prototype or measure when the decision is expensive to reverse: load test the database, benchmark the serialisation format, price the managed service at projected scale.
- Decide, and record it in an architecture decision record (ADR): context, options, decision, consequences, and the trigger to revisit.
- Build in mitigations for the downside you accepted: caching for a slower normalized read, reconciliation for eventual consistency, idempotency for async retries.
- Monitor the trigger metrics, such as replication lag, cost per request, p99 latency and queue depth, so you know when a trade-off has stopped fitting.
# ADR-014: Feed generation strategy (template)
Status: Accepted (2026-03-02)
Context: Read:write ratio ~100:1; feed p99 < 200 ms; 0.01% of users have > 1M followers.
Options: (A) fan-out on write (B) fan-out on read (C) hybrid
Decision: (C) hybrid: precompute for accounts < 100k followers; merge others at read time.
Gains: Feed read = 1 cache read + small merge (~5-20 ms).
Costs: Two code paths; write amplification up to 100k writes per post.
Mitigation: Async fan-out workers, rate-limited; celebrity posts cached separately.
Revisit if: Fan-out queue lag p99 > 30 s, or read-time merge p99 > 120 ms.Trade-offs#
| Trade-off | Pick the first when | Pick the second when |
|---|---|---|
| Consistency vs availability | Money, scarce resources, irreversible actions | Content consumption, approximate data, errors worse than staleness |
| Strong vs eventual | Stale reads cause harm | Brief staleness is harmless (add session guarantees) |
| Latency vs throughput | Interactive, user-facing paths | Pipelines, ingestion, backfills |
| Push vs pull | Freshness matters, consumers known and online | Consumers vary in speed, need replay, or sleep |
| Sync vs async | Caller needs the result now | Slow, unreliable, bursty or fan-out work |
| REST vs RPC | Public, cacheable, browser-facing APIs | Internal, low-latency, streaming, polyglot calls |
| Stateless vs stateful | Default for app tiers | Hot, large state bound to computation; long-lived connections |
| Batch vs stream | Completeness and cost matter most | Value decays within minutes |
| Normalized vs denormalized | System of record, frequent updates | Read models, huge read volume, sharded data |
| Read- vs write-optimised | Read-heavy catalogues, analytics | Ingest-heavy logs, metrics, events |
| Cache-aside vs write-through | General default, cache failure tolerated | Read-immediately-after-write data |
| Long polling vs WebSockets | Moderate updates, simple infrastructure | Frequent two-way, low-latency messaging |
| Concurrency vs parallelism | I/O-bound work | CPU-bound work |
| Vertical vs horizontal | Early, simple, consistency-heavy | Beyond one machine, fault tolerance needed |
| Cost vs performance | Internal and cold paths (save) | Revenue-critical hot paths (spend) |
| Build vs buy | Core differentiator, huge scale | Commodity capability, early stage, small team |
Common Pitfalls#
- Choosing technologies before requirements, then justifying them afterwards.
- Treating trade-offs as global ("our system is eventually consistent") instead of per feature.
- Ignoring operational cost, such as on-call, upgrades and expertise, when comparing options.
- Optimising average latency while the p99 is what users feel.
- Picking WebSockets, Kafka or microservices for scale the system will never reach.
- Denormalizing without a plan to keep copies in sync, or to detect drift.
- Treating timeouts in async integrations as failures, leading to double charges or lost orders.
- Never revisiting a decision after the scale or the requirements change.
Real-World Examples#
Amazon's Dynamo paper (2007) is a case study in deliberate trade-offs. Amazon chose availability and low latency for the shopping cart over strong consistency, accepting occasional merge anomalies, because a failed "add to cart" loses sales.
Google Spanner (2012) made the opposite choice for its workloads. It accepts higher write latency, from synchronous Paxos replication and commit waits based on TrueTime, to provide strongly consistent, globally distributed transactions.
Jeff Bezos's 2015 letter to Amazon shareholders distinguished Type 1 decisions, which are irreversible "one-way doors" deserving careful deliberation, from Type 2 decisions, which are reversible "two-way doors" that should be made quickly. The distinction is now widely used in engineering to decide how much analysis a trade-off deserves.
Dropbox has described moving the majority of its user data from Amazon S3 to its own storage system, Magic Pocket, around 2016. That is a build-vs-buy reversal justified by its scale.
Michael Nygard's 2011 post "Documenting Architecture Decisions" introduced the lightweight ADR format many teams use to record trade-offs.
In the Interview#
Deep Dive: Making trade-offs quantitativeShow
Most trade-off arguments get much clearer once you put numbers on both sides. Four techniques help.
1. Cost per unit of value. Convert options into the same unit, usually dollars per month or per million requests, and compare against the value delivered.
- Example: caching cuts database reads by 90%. If the database tier costs $20,000 per month and must otherwise grow by 3x for next year's traffic, the cache's $3,000 per month avoids about $40,000 per month of growth.
2. Error budgets as a currency. An SLO of 99.9% availability allows ~43 minutes of downtime per month. Spending part of that budget on faster, riskier deployments, or on a simpler architecture with a single region, is a trade-off you can reason about explicitly:
- "We will accept a 15-minute regional failover RTO, using 1/3 of the budget, in exchange for not running active-active, which would double infrastructure."
3. Pareto frontiers. Plot options on two axes, such as p99 latency vs monthly cost. Options that are worse on both axes than some other option are dominated and can be discarded. The remaining options form the frontier, and choosing among them is a genuine value judgement. Naming the frontier keeps discussions from going in circles over clearly inferior options.
4. Sensitivity analysis. Ask which assumption, if it were wrong by 2-10x, would flip the decision.
- If fan-out on write is chosen assuming average follower counts of 200, what happens at 2,000? If the write volume becomes unaffordable, the decision is fragile. Either add a mitigation, such as the celebrity hybrid, or monitor that assumption.
- Decisions that hold across a wide range of assumptions are robust and need little monitoring.
Reversibility as a dimension. Weight each option by how expensive it is to undo.
- Choosing a primary database or a public API contract is a one-way door: data migrations and client breakage are costly.
- Choosing a cache library, a queue for an internal job, or an instance type is a two-way door.
Spend analysis proportional to irreversibility, and prefer designs that keep doors two-way: abstraction at boundaries, dual-write migration paths, versioned APIs.
Deep Dive: Trade-offs compound, and second-order effectsShow
Decisions interact, and the second-order effects often matter more than the first.
- Async + eventual consistency + denormalization. Each is reasonable alone. Together, a user action now produces an event, several consumers update several copies asynchronously, and the user's view can be inconsistent in several places at once. Mitigations must be designed together:
- idempotent consumers keyed by event ID;
- version checks so out-of-order events do not overwrite newer data;
- read-your-writes for the acting user;
- reconciliation jobs that compare each copy with the source.
- Stateless services + shared cache. Moving state out of services makes them easy to scale, but concentrates load on Redis. Hot keys and cache outages then become the main availability risk, so you add local L1 caches, request coalescing and circuit breakers. That is a small amount of state reintroduced, deliberately.
- Microservices + synchronous calls. Each service call adds latency, and availabilities multiply. Ten services at 99.9% in a request path give about 99.0%, around 7 hours of downtime a month. That pushes designs toward asynchronous messaging, caching of dependency results, and graceful degradation, which in turn bring eventual consistency.
- Batching for throughput + strict latency SLOs. Batch sizes and linger times must be tuned so that the batch window fits inside the latency budget. A 50 ms batch window inside a 100 ms p99 budget leaves little room for everything else.
- Buying a managed service + availability targets. Your availability can be no better than the vendor's SLA, multiplied across every vendor in the path, unless you add fallbacks such as a second provider or cached results. Payments platforms often integrate two processors for this reason, accepting the extra integration and reconciliation work.
The general lesson. Evaluate a design as a whole, under failure and under growth, not decision by decision. Walk through a few end-to-end scenarios:
- a write from one user and a read from another;
- a dependency outage;
- a 10x traffic spike;
- a region failure.
Check that the accepted downsides of each choice do not combine into an unacceptable outcome.
Deep Dive: Decision frameworks used in practiceShow
Architecture Decision Records (ADRs). Short documents, one per significant decision, kept with the code. Each records the context, the options considered, the decision, its consequences and its status. Their value grows over time: when someone asks "why on earth do we use X?" two years later, the ADR shows the requirements of the time, and whether those requirements still hold.
ATAM. The Architecture Tradeoff Analysis Method, developed at Carnegie Mellon's Software Engineering Institute, is a structured review that does three things:
- It elicits quality attribute scenarios, such as "under 10x load, p99 stays under 300 ms", from stakeholders.
- It maps architectural decisions to those scenarios.
- It identifies sensitivity points, decisions that strongly affect one attribute, and trade-off points, decisions that affect several attributes in opposite directions.
Few teams run full ATAM, but its vocabulary helps any design review.
"It depends" done well. Senior engineers often answer design questions with "it depends", which is useless unless it is followed by on what. A good answer lists the deciding factors and the choice for each likely value. For example: "For under ~10k writes per second with strong consistency needs, a single Postgres primary. Beyond that, if the data partitions cleanly by tenant, shard by tenant. If it doesn't, consider a distributed SQL database and accept higher write latency."
Defaults that are usually right, and that you should deviate from only for a stated reason:
- a relational database as the system of record;
- stateless app servers;
- cache-aside with TTLs;
- async processing for slow side effects;
- REST at the edge and gRPC inside;
- managed services for commodity capabilities;
- eventual consistency for reads, with strong consistency for the few operations that protect invariants.
Knowing the defaults lets you spend discussion time on the decisions that are genuinely specific to the problem.
Key Takeaways#
- Every design decision trades one property for another; the right choice depends on stated requirements, not on fashion.
- Choose per feature: strong consistency for money and scarce resources, eventual for consumption paths, with session guarantees to hide anomalies.
- Batching and high utilisation raise throughput at the cost of latency; geo-sharding can improve both by serving users close to home, with scatter-gather only at boundaries.
- Push gives freshness, pull gives control and replay, and hybrids (push a signal, pull the data; fan-out hybrids) are common.
- Async decouples and absorbs load but brings duplicates and eventual results; when depending on async external systems, model uncertainty with idempotency, state machines and reconciliation.
- Keep app tiers stateless, normalize the system of record, and build denormalized, read-optimised models from it through events.
- SSE for one-way server push, WebSockets for frequent two-way messaging, long polling as a fallback; concurrency for I/O-bound work, parallelism for CPU-bound work.
- Spend for performance on revenue-critical hot paths; buy commodity capabilities, and build what differentiates you.
- Present trade-offs in five steps (options, requirement, quantified gains and costs, mitigation, revisit trigger) and record them in ADRs.