← Concepts

阅读中文版本

Equal-Cost Multipath Routing

ECMP spreads traffic across several equal-cost network paths, improving throughput and resilience but fragmenting flows unless hashing keeps a flow on one path.

http

Definition

Equal-cost multipath is a routing strategy that selects among multiple next hops of identical cost so that traffic is load-balanced across redundant links or routers.

Context and scope

It underpins spine-leaf data centre fabrics and any network where several links must carry traffic toward the same destination.

Common misconceptions

  • ECMP reorders packets within a single TCP connection harmlessly
  • ECMP is the same mechanism as application-layer load balancing

Anti-patterns

  • hashing on a field that varies per packet rather than per flow
  • assuming path symmetry that does not exist across ECMP

Related concepts

Authoritative source

https://datatracker.ietf.org/doc/html/rfc2992

Definition

Equal-cost multipath is a routing strategy that selects among multiple next hops of identical cost so that traffic is load-balanced across redundant links or routers.

It underpins spine-leaf data centre fabrics and any network where several links must carry traffic toward the same destination. Compared to simpler alternatives, this concept fits best when the trade-off it represents is the one the system actually cares about.

When to use it

A common use case is applying it at the boundary where the cost of getting it wrong is highest, and the scenario usually involves a concrete guarantee the system must uphold. Unlike an ad hoc approach, it makes that guarantee explicit, reviewable, and testable.

How it works

Routers hash source and destination addresses, sometimes ports, to keep a given flow on one path; when the hash includes fields that change per packet, packets reorder and transport performance collapses.

Unequal flow sizes cause imbalance because a small number of elephant flows can pin to one link while others stay idle, which is why some fabrics add flowlet switching.

Trade-offs and alternatives

Because ECMP exposes asymmetric paths, stateful middleboxes and anycast deployments must tolerate packets arriving out of order or from different upstreams. The main drawback is the extra complexity it introduces, so the benefit should clearly outweigh that cost before a team adopts it.

Common misconceptions

A persistent misconception is that ECMP reorders packets within a single TCP connection harmlessly. Another is that ECMP is the same mechanism as application-layer load balancing. For example, an engineer who assumes otherwise may design around a guarantee that does not actually exist, which only becomes obvious under load or failure.

Anti-patterns to avoid

Two recurring anti-patterns are to hashing on a field that varies per packet rather than per flow and to assuming path symmetry that does not exist across ECMP. Both tend to surface as hard-to-debug production issues rather than obvious test failures. Related concepts include TCP Zero Window and Flow Control, MIME Type Sniffing and nosniff, Server Name Indication (SNI).