Load Balancing a UDP server

Linux Virtual Server is a highly scalable and highly available server built on a cluster of real servers. LVS supported UDP protocol and source hash algorithm(this is used when you want a client to always appear on the same realserver).

I use LVM to balancing DNS(rr),SIP(sh).


Interesting. Most of the proxy software I've seen is admittedly TCP based.

Most of the UDP-specific load balancing that I've seen in my meager experience has been DNS-based (ie: time servers, DNS servers, etc). Is there any way to provide multiple A records? If that would work, the normal DNS Round Robin would ensure fair distribution of requests (probably fair enough, anyway) and client caching would ensure that the fidelity was retained (assuming you're using a cache-based platform on the client end).


I have a udp server, [...] server is almost entirely stateless [..] have some fidelity, I mean if client X was routed to server y, then I want all of X's subsequent requests to go to server Y, as long as it is sensible and not overloads Y.

So, you're using an undisclosed application protocol that keeps some application state, and runs on top of UDP? You're kind of going in a difficult direction. UDP is not a reliable data transport, that's the whole point of it -- for reliable data transport see its popular friend TCP. The only way you can get your 'fidelity' is by having a load balancing proxy which understands your application layer protocol, and which knows what your current application state is and can act accordingly.

I see 3 approaches that come close to providing what you seek:

  • Statically spread incoming connections out over 3 IP addresses, based on source (end user) IP address. This way a given user will always be directed to the same server. Most professional firewalls can do this for you. You may have to make the 3 servers highly available yourself, as most firewalls won't do backend health checks for you.

  • Use DNS, and use DNS Round Robin, as already suggested by Matt Simmons.

  • Use Windows's built-in Network Load Balancing (NLB). Honestly, I don't know how the failover scenario would play out with NLB and your semi-stateful UDP based service -- you would have to investigate that yourself, based on how your application handles state. On the plus side, NLB is very easy to set up, free of charge with the Windows license, mature, and well performing.