Is it possible to do this kind of load balancing in the cloud say for example in Digital Ocean if all of my droplets are from the same data center? Or do I need some sort of physical device to do this kind of layer 4 load balancing?

As it is shown here: http://blog.haproxy.com/2011/07/29/layer-4-load-balancing-direct-server-return-mode/

I like the idea that the load balancer just distributes and then the servers reply the request directly to the clients. Is this possible to do without physical hardware, but with software like haproxy?

  • Why would it matter if the load-balancer was physical or virtual? – GregL Apr 26 '16 at 21:41
  • Because in the article from the link above in my post someone said in the comment section that you would not do that in haproxy. So I'm not sure if it matters, if you can or not. – Alex Apr 26 '16 at 22:15
  • Just because you wouldn't, doesn't mean you can't. However, generally that person is right, you wouldn't do DSR with HAProxy because that's not the intended way to set it up. – GregL Apr 26 '16 at 22:41
  • But If I wanted to do DSR, how should I do it? If not with haproxy? – Alex Apr 27 '16 at 0:00
  • 1
    I'd say that LVS would be your best bet. – GregL Apr 27 '16 at 0:04

DSR is implemented in the Linux Kernel (IPVS) which only works with LVS (Linux Virtual Server). You will also need a health checking daemon like keepalived or ldirectord. BTW DSR does not work in Amazon AWS or in Azure due the to the network virtualisation security that they use. It won't work in things like Docker either.


  • Do you think it will work on Digital Ocean? If it is on the same data center? – Alex Apr 28 '16 at 16:20
  • By the way Haproxy can do layer 4 tcp load balancing too. But I guess that is not DSR but NAT I'm I correct? Will this work on for example Digital Ocean if the nodes are in the same data center? – Alex Apr 28 '16 at 16:28
  • As long as Digital Ocean does not block MAC spoofing on the switch infrastructure then DSR mode should work fine, try it and see. Why do you want DSR anyway? Usually the reason is extreme performance and source IP transparency. HAProxy can go pretty fast and works across any network. – Malcolm turnbull May 2 '16 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.