udp traffic with Iperf for haproxy

时光总嘲笑我的痴心妄想 提交于 2019-12-03 17:30:06
helmbert

As I read it, this question is more about UDP load balancing than Docker. Please feel free to correct me if I misread the question.

You probably won't like this answer, but here goes. HAProxy does not support UDP. The official homepage describes HAProxy as TCP and HTTP proxy explicitly (by implication, this means "no UDP"). There are also this question on ServerFault regarding the topic of UDP load balancing, which also discusses and quickly dismisses HAProxy.

Since I don't like "that's not possible, deal with it" as an answer myself, let's have a look at alternatives.

  1. Some resources that ask about UDP load balancing end up recommending IPVS as load balancer. It's part of the Linux kernel, which makes it a bad solution if you're looking for something based on Docker. If that's not a deal breaker for you, there a short example on the Wikipedia page that can be adjusted to your scenario with three UDP servers:

    ipvsadm -A -u 172.17.4.230:5001 -s rr
    ipvsadm -a -u 172.17.4.230:5001 -r 172.17.4.227:5001 -m
    ipvsadm -a -u 172.17.4.230:5001 -r 172.17.4.228:5001 -m
    ipvsadm -a -u 172.17.4.230:5001 -r 172.17.4.229:5001 -m
    
  2. A quick Google search turns up alternative open-source solutions like Pen. Might also be worth a look?

  3. Sure you can't use TCP instead? ;)

As of March 2016 the best solution to this problem is currently Nginx >=1.9.13 :

https://www.nginx.com/blog/announcing-udp-load-balancing/

You can configure HA and health checks for UDP upstreams just like you would a back end TCP reverse proxy. For my project we implemented a solution using a custom container from the base Nginx container (which may be relevant to OP's docker use case), which can be found here:

https://hub.docker.com/_/nginx/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!