# Erasure Coding versus Tail Latency

DevFeed: [Erasure Coding versus Tail Latency](<https://devfeed.tech/articles/erasure-coding-versus-tail-latency-12531.md>)

Original publisher: [Read original article](<http://brooker.co.za/blog/2023/01/06/erasure.html>)

Author: Marc Brooker

Published: 2023-01-06T00:00:00Z

Content type: article

Language: en

Sources: [Marc Brooker's](<https://devfeed.tech/sources/marc-brooker-s-blog.md>)

Topics: [performance-engineering](<https://devfeed.tech/topics/performance-engineering.md>), [Service fabric](<https://devfeed.tech/topics/service-fabric.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [RAID](<https://devfeed.tech/topics/raid.md>), [rate-limiting](<https://devfeed.tech/topics/rate-limiting.md>), [in-memory database](<https://devfeed.tech/topics/in-memory-database.md>)

Tags: [coding](<https://devfeed.tech/tags/coding.md>), [communication](<https://devfeed.tech/tags/communication.md>), [durability](<https://devfeed.tech/tags/durability.md>), [latency](<https://devfeed.tech/tags/latency.md>), [object-storage](<https://devfeed.tech/tags/object-storage.md>), [radio](<https://devfeed.tech/tags/radio.md>), [scale](<https://devfeed.tech/tags/scale.md>), [storage](<https://devfeed.tech/tags/storage.md>)

## AI overview

Erasure coding can reduce cache fetch latency and improve availability while using less storage than duplicating every object. In the example, an object is encoded into five pieces and can be reconstructed from any four: fetching all five and using the first four to arrive adds 5x request overhead, with 20% worst-case bandwidth and storage overhead. The cited measurement reports about a 20% reduction in median latency and a large tail-latency improvement versus fetching four of four shards in parallel. Unlike hedging, which duplicates requests and mainly helps at the tail, this scheme can also improve lower percentiles. It tolerates up to M−k component failures under the described independent-failure assumption, and flexible shard selection can spread load, though schemes with low k may carry high write and storage costs. The excerpt also cautions that hedged requests can amplify correlated slowdowns; a token bucket can cap their extra load.

## Source excerpt

Erasure Coding versus Tail Latency There are zero FEC puns in this post, against my better judgement. Jeff Dean and Luiz Barroso's paper The Tail At Scale popularized an idea they called hedging, simply sending the same request to multiple places and using the first one to return. That can be done immediately, or after some delay: One such approach is to defer sending a secondary request until the first request has been outstanding for more than the 95th-percentile expected latency for this class of requests. Smart stuff, and has become something of a standard technique for systems where tail latencies are a high multiple of the 50th or 95th percentile latencies1. The downside of hedged requests is that it's all-or-nothing: you either have to send twice, or once. They're also modal, and don't do much to help against lower percentile latencies. There's a more general technique available that has many of the benefits of hedged requests, with improved flexibility and power to reduce even lower percentile latencies: erasure coding. What is Erasure Coding? Erasure coding is the idea that we can take a blob of data, break it up into M parts, in such a way that we can reconstruct it from any k of those M parts2. They're pretty ubiquitous in storage systems, block storage, object storage, higher RAID levels, and so on. When storage systems think about erasure codes, they're usually thinking about durability: the ability of the system to tolerate $M - k$ disk or host failures without losing data, while still having only $\frac{M - k}{M}$ storage overhead. The general idea is also widely used in modern communication and radio protocols3. If you're touching your phone or the cloud, there are erasure codes at work. I won't go into the mathematics of erasure coding here, but will say that it is somewhat remarkable to me that they exist for any combination of k and M (obviously for $k \leq M$). It's one of those things that's both profound and obvious, at least to me. Erasure Cod