skip to content

After a cluster's connections were encrypted, readers replaying old history slowed far more than caught-up readers — why?

level: seniorimportance: should knowfreq 52%

answer

  1. speed came from not touching bytes
  2. transforming output ends the shortcut
  3. cost scales with bytes shipped
  4. replays and rebuilds ship the most

basics

~20 s

Encryption forces the node to handle bytes it previously never touched, closing the copy-free read path from stored file to network. The added work scales with bytes shipped, and a history replay ships the most bytes fastest; a caught-up reader trickles.

solid answer

~40 s

Some platforms are fast on reads because the serving node never handles the bytes: a reader asks for a range of stored records and the node has the operating system send that range straight out, with nothing copied into the process. That is the copy-free read path, and an encrypted connection forecloses it — the process must hold each byte to encrypt it. The remaining arithmetic is cheap on current processors with bulk-encryption instructions; what actually costs is the copying and the lost shortcut, and both scale with bytes shipped. A caught-up reader takes a trickle of recent records, often still in the operating system's file cache. A reader replaying history, or a node rebuilding a copy, moves bytes as fast as the cluster allows, so it pays the largest share.

go deeper

for a junior

Recall that protecting a connection is not free, and that the price is charged per byte moved rather than per connection opened.

for a middle

Explain the mechanism: serving stored bytes straight to the network requires sending them unchanged, so encryption forces the process to handle every byte itself.

for a senior

Show you know where the cost concentrates — replays and node rebuilds, not steady-state reads — and that you size headroom and rebuild windows against exactly those flows.

for a principal

Frame it as a purchase: the throughput given up buys confidentiality on every hop. Decide the rule for the whole estate and fund the headroom rather than carving out exceptions per cluster.

## Where the read speed came from in the first place On platforms whose records are appended to files and served from them, read throughput has an unusual property: the node barely participates. A reader asks for a range of stored records; the node identifies the region of the file that holds them and asks the operating system to send that region to the network connection. The bytes travel from the operating system's file cache out to the reader **without ever being copied into the serving process's own memory**. That is the **copy-free read path**, and it is why such a cluster can serve far more read bytes per second than its own processing would suggest. The path has a precondition that is easy to miss: the bytes leaving must be byte-for-byte the bytes stored. The moment they must be transformed on the way out, the process has to hold them. ## What an encrypted connection takes away - **The shortcut itself.** Encrypting output means transforming it, so the serving process must obtain every byte, transform it, and write the result. The stored region can no longer be handed to the network untouched. - **Extra copies and memory bandwidth.** Each byte now moves through the process rather than past it. On a node serving many gigabits, this is felt as processor time and memory traffic rather than as disk load. - **Per-connection setup work.** Establishing a protected connection costs more than establishing a plain one. Normally invisible, it becomes visible in a burst when a large client population reconnects at once. - **What it does *not* mainly cost: the arithmetic.** Current processors carry bulk-encryption instructions that make the transformation itself cheap per byte. A candidate who attributes the whole slowdown to "encryption maths" has the wrong model; the copying and the lost shortcut dominate. ## Why the bill lands on the history readers 1. **The added work is proportional to bytes shipped.** Not to connections, not to records, not to record age — to volume. 2. **A caught-up reader ships very little.** Its byte rate is bounded above by the write rate of what it follows, it usually asks for small recent ranges, and those ranges are frequently still in the operating system's file cache. It pays, but it pays at the rate the stream is being written. 3. **A replay is unbounded by comparison.** A reader rebuilding state from the start of retention, or a node rebuilding a copy from scratch after being replaced, pulls as fast as the cluster will let it. It is the single highest byte-rate flow in the cluster, and it is precisely the flow that used to be almost free. | Flow | Byte rate | Used the copy-free path | How the change is felt | |---|---|---|---| | Reader already caught up | Bounded by the write rate | Yes, on a small recent range | Slight, steady processor cost | | Reader replaying history | As fast as permitted | Yes, on large cold ranges | Large; the replay takes visibly longer | | Node rebuilding a copy | Highest in the cluster | Yes | The rebuild window stretches, so the cluster runs short of copies for longer | | Writer sending records | Bounded by the application | No — writes were never copy-free | Modest; writes always passed through the process | That last row is worth saying out loud in an interview: the write path never had the shortcut, so encryption does not change writes in the same way it changes reads. The asymmetry is the interesting part. ## This is a claim about a shape, not about every broker - On **log-shaped platforms serving reads from stored files**, the change is largest, because the shortcut existed and is now gone. - On a **queue-shaped broker that holds messages in memory and removes them once acknowledged**, there was never a copy-free read path to lose. The process already handled every byte, so the added cost is the per-byte transformation and the per-connection setup — real, but a different and usually smaller story. - On a **rented cluster**, member traffic is often encrypted already and the cost is inside the price. You will not see the difference; you also cannot choose it. Published figures for the throughput drop vary widely and depend entirely on record size, batch shape, how much history is being replayed and what the hardware is. Quoting one number as the answer is a mistake — the defensible claim is the mechanism and the direction. ## What to do with this in practice - Encrypt anyway, and budget for it: the answer to "it costs throughput" is capacity headroom, not leaving payloads in the clear. - Size the headroom against your **replay and rebuild** traffic, not against steady-state reads, because that is where the cost concentrates. - Expect a node rebuild to take longer once member traffic is protected, and account for that in how long the cluster tolerates running with fewer copies. - Measure on your own workload. A benchmark run on a different record size answers a different question.

  • Why is the per-byte encryption arithmetic usually not the main cost?
    Current processors carry instructions for bulk encryption, so transforming a byte is cheap. What is not cheap is that the bytes must now pass through the serving process at all: the copying and the loss of the send-straight-from-storage shortcut are what the node actually pays.
  • Which flow on a cluster shows this cost first?
    A node rebuilding a copy from scratch. It moves history at the highest byte rate in the cluster, so it is the flow most exposed to a per-byte cost — and because the rebuild takes longer, the cluster spends more time with fewer copies than it wants.
  • Does the same reasoning apply to the writer's connection?
    Only partly. Records arriving from a writer were always handled by the process — they are parsed, placed and appended — so no shortcut is lost there. Writes pay the per-byte transformation and the connection setup, but not the structural change that reads pay.

saying these in an interview costs you the question

  • Blames the slowdown on encryption arithmetic being expensive per byte
  • Believes the cost is per connection, so a replay costs what an idle reader costs
  • Thinks encrypting connections slows writes as much as reads
  • Assumes every broker had a copy-free read path to lose
  • Quotes a single published throughput-drop percentage as the answer
  • Concludes the fix is to leave the internal hop unencrypted