Step-by-step guide to setting up DSR for high-throughput applications
4 min read
Direct Server Return (DSR) allows backend servers to respond directly to clients, bypassing the load balancer on the return path. For workloads with asymmetric traffic patterns -- where responses are much larger than requests -- DSR can reduce load balancer bandwidth requirements by 90% or more.
DSR is the right choice when your workload has large responses relative to requests:
If your service requires Layer 7 features such as content-based routing, cookie persistence, or HTTP header manipulation, DSR is not appropriate. Use a standard L7 VIP instead.
Tula supports two DSR modes, and the choice depends on your network topology:
Layer 2 DSR (MAC rewrite) -- The load balancer rewrites the destination MAC address of incoming packets to the selected backend's MAC address. The IP headers are untouched. This requires all backends to be on the same Layer 2 network segment (VLAN) as the load balancer. L2 DSR has the lowest overhead and is the preferred mode when the network topology allows it.
Layer 3 DSR (IPIP tunneling) -- The load balancer encapsulates the original packet inside an IP-in-IP tunnel to the backend server. The backend decapsulates the outer header and processes the original packet. This works across subnets and routed networks, making it suitable for backends in different data centres or VLANs. L3 DSR adds a small overhead due to encapsulation (20 bytes per packet).
streaming-dsr).80, 443, or * for all ports).Each backend server must accept traffic destined for the VIP address and suppress ARP responses for that address. On each Linux backend, run the following commands (replace 10.0.1.100 with your VIP address):
# Add the VIP to the loopback interface
ip addr add 10.0.1.100/32 dev lo
# Suppress ARP responses for the VIP
sysctl -w net.ipv4.conf.all.arp_ignore=1
sysctl -w net.ipv4.conf.all.arp_announce=2
To make these changes persistent across reboots, add the IP to your network configuration and add the sysctl entries to /etc/sysctl.d/99-dsr.conf:
net.ipv4.conf.all.arp_ignore=1
net.ipv4.conf.all.arp_announce=2
For L3 DSR (IPIP tunneling), you must also enable the IPIP tunnel interface on each backend:
modprobe ipip
ip link add ipip0 type ipip local <backend-ip> remote any
ip link set ipip0 up
ip addr add 10.0.1.100/32 dev ipip0
curl -v http://10.0.1.100/
ip addr show lo on each backend to confirm.arp_ignore and arp_announce are set correctly with sysctl net.ipv4.conf.all.arp_ignore.ipip kernel module is loaded (lsmod | grep ipip) and that the tunnel interface is up on each backend. Check that no firewalls are blocking IP protocol 4 (IPIP).