概念概述
等价多路径路由(ECMP)(Equal-Cost Multipath Routing)指的是:ECMP 在多条等价开销的路径上分摊流量以提升吞吐与容灾,但若哈希未按流进行,单一 TCP 连接会发生乱序并拖垮性能。
从更严格的定义看,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. 它与 TCP Zero Window and Flow Control、MIME Type Sniffing and nosniff、Server Name Indication (SNI) 等概念经常一起出现,用于解决相近的工程问题。理解它的适用场景,有助于在多种备选方案之间做出有依据的取舍,而不是凭直觉选择技术方案。
常见误解
- ECMP reorders packets within a single TCP connection harmlessly
- ECMP is the same mechanism as application-layer load balancing
需要避免的反模式
- hashing on a field that varies per packet rather than per flow
- assuming path symmetry that does not exist across ECMP
实践要点
- 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.
- Because ECMP exposes asymmetric paths, stateful middleboxes and anycast deployments must tolerate packets arriving out of order or from different upstreams.