Skip to content

MinIO Erasure Coding Deep Dive: From Mathematical Principles to Production Practice ​

MinIO erasure coding principle diagram

1. What is erasure coding? ​

Erasure coding (Erasure Code, EC) is a kind of Data protection algorithms, it splits the original data into several data blocks and computes additional parity blocks through encoding. When some data blocks are lost or corrupted, the remaining data blocks and parity blocks can be used Reconstruct the complete data.

In distributed storage systems, the core problem solved by erasure coding is:How can storage space utilization be maximized while ensuring data reliability?

1.1 Why is erasure coding needed? ​

Reviewing the evolution of data protection in the storage field:

PlanStorage efficiencyReliabilityTypical scenario
No redundancy100%❌ A single point of failure means data lossTemporary cache
2 copies50%Tolerate 1 device failureEarly distributed storage
3 copies33.3%Tolerate 2 failuresHDFS, Ceph (old version)
Erasure coding 8+466.7%Tolerate 4 machine failuresMinIO default

Conclusion: Under the same reliability, erasure coding has much higher storage efficiency than multiple replicas. MinIO adopts 8+4 Erasure coding, use 1.5 times storage overhead achieved compared to 3 replicas (3x overhead) Higher fault tolerance.

2. Mathematical Principles of Erasure Coding ​

The erasure coding implementation used by MinIO is based on Reed-Solomon (RS) code, This is a classic erasure coding algorithm, widely used in RAID 6, CDs, QR codes, and various distributed storage systems.

2.1 k+m model ​

The core of Reed-Solomon codes is k+m model:

  • k(Data Shards): Number of data shards; the original data is split into k parts.

  • m(Parity Shards): Validate the number of parity shards and generate m pieces of parity data through encoding computation.

  • Total number of shards: n = k + m

Fault tolerance: as long as any k If a shard survives, the complete data can be reconstructed. That is, it can tolerate at most m a shard is lost.

2.2 Encoding Process (Illustrated) ​

Assume k=4, m=2(4 data blocks + 2 parity blocks):

when B and D When lost:

Core Principles: RS code by constructing a the generator matrix of k × (k+m) mapping k data blocks to k+m encoded blocks. During decoding, extract a submatrix from the surviving blocks and solve the system of linear equations to recover the original data.

2.3 Mathematical Formulas (for technical depth reference) ​

Let the original data vector be D(k elements), the generated matrix is G(k × (k+m)), encoding result E = D×G.

When some shards are lost, from G extract from ... the rows corresponding to the surviving shards, forming G', surviving data E'=D×G'. Due to G' Reversible,D=E'×G'⁻¹, the data was reconstructed.

If you are interested in specific Galois Field operations, I recommend reading Backblaze's Reed-Solomon Implementation Explained in Detail.

3. Erasure Coding Implementation in MinIO ​

3.1 Default Policy ​

MinIO's erasure coding configuration and Number of drives Directly related:

Number of drivesDefault erasure coding configurationTolerable number of faultsStorage utilization rate
1No erasure coding (single-disk mode)0100%
21+1150%
32+1166.7%
42+2250%
53+2260%
64+2266.7%
74+3357.1%
84+4(Default)450%
8+Automatically select the optimal ratioabout n/2About 50%

📌Attention: MinIO Official Recommend at least 8 drives to obtain a better erasure code configuration. In actual production,8+4(12 plates) or 8+8(16 drives) is a common configuration.

3.2 Storage Space Utilization Calculation ​

with 3 copies and Erasure coding 8+4 Taking the comparison of ... as an example:

PlanPhysical space required to store 1 TiB of valid dataNumber of simultaneous disk failures allowedutilization rate
3 copies3 TiB233.3%
Erasure coding 8+41.5 TiB466.7%

With the same physical storage space, erasure coding can store 2 times valid data with 3 replicas, while fault tolerance is doubled.

3.3 Impact of Erasure Set (Erasure Set) ​

MinIO divides drives into several Erasure Set, each Set is independently erasure-coded.

Example: 32 drives,8+4 erasure code

Erasure Set 1: Drives 1-12
Erasure Set 2: Drives 13-24
Eraser Set 3: drives 25-32 (only 8 disks, use 4+4)

Performance impact:

  • The larger the Erasure Set: A single read/write involves more disks,Higher throughput, but a single disk failure has a larger impact scope.

  • The smaller the Erasure Set: Better fault isolation, but slightly lower concurrent read/write performance.

MinIO official recommendation: Each Erasure Set contains 8 to 16 drives, achieving a balance between performance and failure domains.

4. Hands-on: MinIO Erasure Coding Deployment and Testing ​

4.1 Multi-disk deployment: Docker local simulation ​

Use Docker to simulate 12 drives, deploy 8+4 Erasure coding mode:

bash
# Create 12 empty directories to simulate disks.
mkdir -p /tmp/minio/{1..12}

# Start MinIO erasure coding mode (12 drives, automatically uses 8+4)
docker run -d \
  --name minio-erasure \
  -p 9000:9000 -p 9001:9001 \
  -e "MINIO_ROOT_USER=minioadmin" \
  -e "MINIO_ROOT_PASSWORD=minioadmin" \
  -v /tmp/minio/1:/data1 \
  -v /tmp/minio/2:/data2 \
  -v /tmp/minio/3:/data3 \
  -v /tmp/minio/4:/data4 \
  -v /tmp/minio/5:/data5 \
  -v /tmp/minio/6:/data6 \
  -v /tmp/minio/7:/data7 \
  -v /tmp/minio/8:/data8 \
  -v /tmp/minio/9:/data9 \
  -v /tmp/minio/10:/data10 \
  -v /tmp/minio/11:/data11 \
  -v /tmp/minio/12:/data12 \
  minio/minio server /data{1..12} --console-address ":9001"

Check the startup log to confirm the erasure code configuration:

log
Formatting 1 pool, 1 set(s), 12 drives per set.
├─ 12 drives, 8 data, 4 parity

4.2 Simulating Disk Failure and Automatic Recovery ​

Step 1: Upload the test file

go
// Upload a 100MB test file.
func uploadTestFile(client *minio.Client) error {
    ctx := context.Background()
    bucketName := "test-bucket"
    objectName := "test-file-100m.dat"

    // Generate 100MB of random data
    data := make([]byte, 100*1024*1024)
    rand.Read(data)
    reader := bytes.NewReader(data)

    _, err := client.PutObject(ctx, bucketName, objectName, reader, int64(len(data)), minio.PutObjectOptions{})
    return err
}

Step 2: View the distribution of objects on disk

MinIO will distribute the object's 8 data blocks and 4 parity blocks across 12 drives.

bash
# View the distribution of objects across data directories
ls -la /tmp/minio/*/test-bucket/test-file-100m.dat/

You will see something like:

/tmp/minio/1/test-bucket/test-file-100m.dat/part.1  # data block
/tmp/minio/2/test-bucket/test-file-100m.dat/part.2  # data block
...
/tmp/minio/9/test-bucket/test-file-100m.dat/part.9  # Check block
/tmp/minio/10/test-bucket/test-file-100m.dat/part.10 # Check block
...

Step 3: Simulate a disk failure

bash
# Stop the container and delete 4 data directories (simulating the simultaneous failure of 4 disks).
docker stop minio-erasure
rm -rf /tmp/minio/{1,2,3,4}
docker start minio-erasure

Step 4: Verify data integrity

go
// Attempt to download the file and verify whether the data is complete.
func verifyDataIntegrity(client *minio.Client) error {
    ctx := context.Background()
    bucketName := "test-bucket"
    objectName := "test-file-100m.dat"

    object, err := client.GetObject(ctx, bucketName, objectName, minio.GetObjectOptions{})
    if err != nil {
        return err
    }
    defer object.Close()

    // Read and verify data (hash verification can be performed here)
    data, err := io.ReadAll(object)
    if err != nil {
        return err
    }

    log.Printf("Successfully restored data, size: %d bytes\n", len(data))
    return nil
}

Expected results: Complete data recovery with no impact on the business. This is because MinIO automatically uses the surviving 8 shards (4 data blocks + 4 parity blocks) during reads to reconstruct the complete data.

5. Erasure Coding Trade-offs and Best Practices ​

5.1 The Triangular Trade-off Between Performance, Space, and Reliability ​

ConfigurationStorage utilization rateReliabilityRead/write performanceApplicable scenarios
4+266.7%Tolerate 2 disk failuresrelatively highSmall-scale deployment, cost-sensitive
8+466.7%Tolerate 4 disk failuresMediumMinIO official recommendation, Balancing plan
8+850%Tolerates 8 disk failureslowerExtremely high reliability requirements
16+480%Tolerate 4 disk failuresHigh throughputBig data analytics, cold storage

Core trade-off principle:

  • the larger k is: The higher the storage utilization, the more disks are involved in each read/write, latency increases slightly, and more data must be read when recovering from a single disk failure.

  • the larger m is: The higher the reliability, but the verification computation overhead increases, and storage costs rise.

  • k+m total: The total number of drives in the Set affects parallelism. The larger the total, the higher the throughput, but the larger the failure blast radius.

Deployment scaleTotal number of drivesRecommended erasure code configurationExplanation
Development/Testing42+2Minimum erasure code configuration
Small-scale production84+4Balance reliability and performance
Medium-scale production128+4Best value for money, the official first choice.
Large-scale production168+8High reliability, suitable for mission-critical business
Hyperscale32+8+4 or 16+4Multiple Erasure Sets in Parallel

5.3 Common Misconceptions ​

MisconceptionCorrect understanding
❌ Erasure coding can replace backups✅ What erasure coding protects is disk failure, not protected Data corruption, accidental deletion, ransomware Backups are still essential.
❌ The more drives, the safer erasure coding.✅ Fault tolerance is determined by m (number of check blocks) determined, not the total number of drives. 16+4 and 8+4 have the same fault tolerance (both 4 drives), but different utilization.
❌ Erasure code reconstruction is slower than replica reconstruction✅ Replica reconstruction only requires copying data, while erasure code reconstruction requires decoding computation. However, on modern CPUs, the overhead of RS encoding is extremely low, and the actual difference is acceptable.
❌ Erasure coding is only suitable for cold storage✅ MinIO’s Go implementation is highly optimized, and erasure coding also performs well in small-object scenarios (especially after inline storage optimization), making it equally suitable for hot storage.

5.4 Monitoring and O&M Recommendations ​

bash
# View the cluster erasure coding health status
mc admin health myminio

# View the status of each Erasure Set
mc admin info myminio --json | jq '.info.sets'

# Monitor erasure code rebuild progress (if there is a failed disk)
mc admin heal myminio

6. Summary ​

dimensionKey points
Why erasure coding?Higher storage efficiency than multiple replicas (66.7% vs 33.3%), stronger fault tolerance (tolerates 4 disk failures vs 2 disks)
Mathematical PrinciplesReed-Solomon encoding, k+m model, any k shards are sufficient to reconstruct the complete data
MinIO default configuration8+4 (12 drives), storage utilization 66.7%, tolerates 4 simultaneous drive failures
Performance trade-offThe larger k is, the higher the utilization; the larger m is, the higher the reliability; choose based on the actual scenario.
Best practicesFor production environments, it is recommended to start with 12 disks (8+4), with both monitoring and backup in place.

MinIO's erasure coding implementation is what enables it to High performance and High Availability the fundamental reason for achieving a perfect balance between them. For storage engineers, a deep understanding of erasure coding not only enables better configuration and tuning of MinIO clusters, but also allows them to draw inferences and apply its design ideas to architectural decisions in other distributed systems.

Erasure coding is not a silver bullet; it cannot replace backups, nor can it eliminate hardware failures. But under limited hardware resources, it is Best engineering practices for maximizing data security and storage efficiency.

📌扩展阅读:

Last updated on11/07/2026, 02:16 PM
@fishfinal | @fishfinals | [email protected]