Data-centre topologies: leaf-spine
Explain why data centres moved from three-tier to leaf-spine designs.
By Invicly Tech, , in Computer Networking. About 11 minutes to read.
In short
Modern data centres carry far more server-to-server traffic than traffic to users, which the old three-tier design handled poorly. Leaf-spine fabrics connect every leaf switch to every spine switch, so any two servers are the same number of hops apart and ECMP spreads load across all paths. Overlays such as VXLAN stretch layer 2 segments across this layer 3 fabric.
Explained simply
A data centre is a building full of servers, connected by switches. How those switches are wired together is called the topology. It decides how fast servers can talk, what happens when a switch dies, and how easily you can grow.
The old design had three levels: access switches for servers, aggregation switches above them, and a core at the top. It was built when most traffic went from users outside to a server inside and back. That is called north-south traffic.
Today most traffic stays inside the building. A single web request can trigger dozens of calls between services, databases and caches. This server-to-server traffic is called east-west. The old three-level design made it travel up and down long, uneven paths.
The modern answer is leaf-spine. Every rack has a leaf switch, and every leaf connects to every spine switch. Any server reaches any other server in the same small number of hops, all links are used at once, and you grow by adding more leaves or spines.
Press Play on a diagram to walk through it one step at a time.
- Access, aggregation, core
- Built for north-south traffic
- STP blocks redundant links
- Uneven path lengths
- Every leaf links to every spine
- Built for east-west traffic
- Layer 3 with ECMP, no STP
- Predictable two-hop paths
- Scale out by adding spines
- Spine 1
- Link to leaf 1
- Link to leaf 2
- Link to leaf 3
- Link to border leaf
- Spine 2
- Link to leaf 1
- Link to leaf 2
- Link to leaf 3
- Link to border leaf
- Leaf 1 to 3 (top of rack)
- Server racks
- Hosts dual-homed to two leaves
- Border leaf
- Firewalls and routers
- North-south exit to WAN and internet
In depth
Why three-tier designs struggled
In a three-tier network, access switches connect to two aggregation switches for redundancy, and those connect to the core. The access layer was usually layer 2, so VLANs stretched across many switches, and redundant links formed loops. Spanning Tree Protocol (STP) prevents loops by blocking links, which means half the bandwidth you paid for sits idle until something fails, and a failure can take seconds to recover.
Paths are also uneven. Two servers on the same access switch are one hop apart, but two servers in different pods may cross access, aggregation, core, aggregation and access again. For east-west heavy apps, latency becomes unpredictable and the aggregation layer becomes a bottleneck. Scaling meant buying bigger, more expensive aggregation and core boxes (scaling up) rather than adding more small ones (scaling out).
- STP blocks redundant links to avoid loops
- Uneven paths give unpredictable latency
- Growth means bigger, costlier boxes
- Large layer 2 domains spread broadcast storms
Leaf-spine and ECMP
In a leaf-spine (also called a Clos) fabric, each leaf, or top-of-rack switch, has one uplink to every spine, and spines do not connect to each other. Traffic from a server on leaf 1 to a server on leaf 7 always goes leaf, spine, leaf: three switches, whichever spine it uses. The links between leaves and spines are routed at layer 3, often with BGP, so there are no loops and no STP.
With four spines, each leaf has four equal-cost paths to every other leaf. ECMP (equal-cost multi-path) spreads traffic across them by hashing each flow's 5-tuple (source IP, destination IP, protocol, source port, destination port). All packets of one flow take the same path, so they stay in order, while different flows spread out. The weak spot is a few huge flows (elephant flows) landing on the same link; good hashing and many flows keep this rare. If a spine fails, ECMP simply uses the remaining ones, losing only a share of capacity.
- 1Packet arrives at leaf
Destination is on another rack
- 2Route lookup
Four equal-cost next hops, one per spine
- 3Hash the 5-tuple
IPs, protocol and ports give a number
- 4Pick next hop
Hash modulo 4 chooses a spine
- 5Same flow, same path
Packets stay in order
Sizing a fabric: oversubscription
Oversubscription compares the bandwidth servers can send into a leaf with the bandwidth the leaf has towards the spines. A leaf with 48 ports of 25 Gbps to servers offers 1200 Gbps downstream. With 6 uplinks of 100 Gbps it has 600 Gbps upstream, a ratio of 2:1. If every server sent at full speed to other racks at once, half would have to wait. In practice not all servers peak together, so 2:1 or 3:1 is common for general workloads, while storage and AI training clusters often aim for 1:1 (non-blocking).
The spine's port count limits the number of leaves, because each leaf needs one port on every spine. A spine with 64 ports supports up to 64 leaves. To go bigger, data centres add another tier of super-spines, forming a multi-stage Clos. The number of uplinks per leaf limits the number of spines.
- Ratio = server-facing bandwidth / uplink bandwidth
- 48 x 25G down and 6 x 100G up = 2:1
- Spine port count caps the number of leaves
- Leaf uplink count caps the number of spines
Overlays: VXLAN and EVPN
A routed fabric is great for the network, but some applications and virtual machines still expect to share a layer 2 segment across racks, and cloud tenants need isolated networks. Overlays solve this. VXLAN wraps the original Ethernet frame inside a UDP packet (destination port 4789) and sends it across the routed fabric. The switch or hypervisor that wraps and unwraps is a VTEP (VXLAN tunnel endpoint).
Each virtual network gets a 24-bit VXLAN Network Identifier (VNI), allowing about 16 million segments instead of 4094 VLANs. The extra headers add 50 bytes (outer Ethernet 14, outer IP 20, UDP 8, VXLAN 8), so fabrics run a larger MTU, such as 9000 or 9216, so that 1500-byte guest frames fit. VTEPs must learn which MAC lives behind which VTEP; modern fabrics use BGP EVPN as the control plane to share that information instead of flooding.
- 1Outer Ethernet
14 bytes, hop to the next fabric switch
- 2Outer IP
20 bytes, source VTEP to destination VTEP
- 3Outer UDP
8 bytes, destination port 4789
- 4VXLAN header
8 bytes, carries the 24-bit VNI
- 5Original Ethernet frame
The tenant's frame, unchanged
Learn it in 4 short steps
About 30m each. Track them with a timer in your plan.
- 1Compare three-tier and leaf-spine designs~30m
- 2Explain east-west versus north-south traffic~30m
- 3Explain ECMP load sharing~30m
- 4Explain overlays such as VXLAN~30m
Key points
- East-west traffic flows between servers; north-south flows in and out of the data centre.
- ECMP hashes flows across equal-cost paths.
- VXLAN encapsulates Ethernet frames in UDP with a 24-bit segment ID.
- BGP is commonly used as the routing protocol inside fabrics.
Key terms
Tap a card to flip it. 0/4 known
Examples
Sizing a fabric for 20 racks
You need 20 racks of 40 servers, each with one 25 Gbps link, and want 2.5:1 or better. Step 1: per leaf, 40 x 25 = 1000 Gbps down. Step 2: with 4 uplinks of 100 Gbps, up is 400 Gbps, a ratio of 2.5:1. Step 3: 4 uplinks per leaf means 4 spines. Step 4: 20 leaves (plus 2 border leaves) need 22 ports on each spine, so a 32-port 100G spine leaves room to grow to 32 leaves. Step 5: for 1:1 later, add uplinks and spines; the design scales out without replacing boxes.
One slow link in an ECMP fabric
Some requests between two services are slow, others are fine. Step 1: since ECMP hashes each flow, a bad link affects only the flows that hash onto it, which explains the some-but-not-all pattern. Step 2: check interface error counters on every leaf uplink; one link to spine 3 shows rising CRC errors. Step 3: shut that link down; ECMP moves its flows to the other three spines within moments. Step 4: replace the optic or cable, then bring the link back.
leaf1# show interfaces counters errors
leaf1# show ip route 10.0.7.0/24 ! expect 4 next hops
leaf1(config)# interface Ethernet52
leaf1(config-if)# shutdown
leaf1# show ip route 10.0.7.0/24 ! now 3 next hopsQuick reference
- North-south: in and out of the data centre; east-west: server to server
- Leaf-spine: every leaf to every spine, spines not interconnected
- Any leaf to any leaf is leaf, spine, leaf: the same hop count every time
- ECMP hashes the 5-tuple so one flow keeps one path and stays in order
- Oversubscription = server bandwidth / uplink bandwidth, e.g. 2:1 or 3:1
- VXLAN: UDP 4789, 24-bit VNI (about 16 million segments), 50 bytes overhead
- Run jumbo MTU (9000+) in the fabric so overlays carry 1500-byte frames
- BGP EVPN is the common control plane for VXLAN fabrics
Quick quiz
Pick an answer to see if you're right and why.
Practice exercises
Try each one yourself first. Use the hint if you get stuck, then compare with the solution.
- Exercise 1easy
Classify these flows as north-south or east-west: a user loading the homepage; the web tier querying the database; a backup job copying data between racks; an API call from a partner.
- Exercise 2medium
Design a fabric for 30 racks with 32 servers each at 25 Gbps and a target ratio of 2:1. How many 100G uplinks per leaf and spines do you need, and how many ports per spine?
- Exercise 3hard
A VM in a VXLAN overlay can ping across racks with small packets, but large file copies hang. Explain the cause and give two fixes.
Check yourself
Answer in your head, reveal, then be honest with yourself.
Feel confident about this topic?
Frequently asked questions
- What is a Clos network?
- A multi-stage switching design described by Charles Clos in 1953 for telephone exchanges. Leaf-spine is a two-stage folded Clos, where every leaf connects to every spine.
- Do I need leaf-spine for a small server room?
- Not usually. With one or two racks, a pair of switches is enough. Leaf-spine pays off when you have many racks and lots of server-to-server traffic.
- Why is BGP used inside data centres?
- BGP scales to very large numbers of routes and devices, supports ECMP, and gives fine control over policy. Many operators run eBGP between leaves and spines.
- What is the difference between VLAN and VXLAN?
- A VLAN tags frames on a layer 2 network and is limited to 4094 IDs. VXLAN carries layer 2 frames inside UDP across a layer 3 network and supports about 16 million IDs.