UDP负载平衡使用定制的平衡方法,并且在UDP主体内部具有会话ID [英] UDP load balancing using customised balancing method with session id inside UDP body

查看:77
本文介绍了UDP负载平衡使用定制的平衡方法,并且在UDP主体内部具有会话ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试建立一个能够平衡UDP流量的负载平衡解决方案.就我而言,我有几台不同的服务器,它们将UDP程序包发送到负载均衡器.在每个UDP包主体中,都有一个MSG-ID字段.理想情况下,我想基于该MSG-ID对一组服务器的UDP流量进行负载平衡.换句话说,应该将具有相同MSG-ID的两个UDP包发送到同一台服务器(因为我要组装具有相同MSG-ID的两个UDP包,以形成一个完整的包以进行进一步处理).但是,如果不可能,那么基于源/发送者IP的解决方案可能就足够了.

I am trying to set up a load balancing solution which is able to load balance UDP traffic. In my case, I have several different servers which send UDP package to a load-balancer. Inside each UDP package body, there is a MSG-ID field. Ideally, I want to load-balance UDP traffic to a set of servers based on that MSG-ID. In other words, two UDP packages with same MSG-ID should be sent to the same server (because i want to assemble two UDP packages with same MSG-ID to form a complete package for further processing). But if it's not possible, then a solution based on source/sender IP might be sufficient.

Haproxy不支持UDP,因此我正在检查nginx.但是似乎只有nginx-plus(不是免费的解决方案)允许您基于ip_hash方法进行负载平衡吗?

Haproxy doesn't support UDP so I am checking nginx. But seems that only nginx-plus (not free solution) allows you to do load-balance based on ip_hash method?

我想知道:

  1. 什么是最好的开源解决方案,可以帮助我基于UDP正文中的自定义MSG-ID处理负载平衡.
  2. nginx(免费/开源)版本至少支持基于ip_hash方法的UDP负载平衡.
  3. 无论如何,我都可以欺骗UDP源/发送者IP.基本上,如果我有服务器(例如服务器A)从多个服务器(服务器D)接收UDP数据包并将其转发到一组服务器(服务器B,C);我希望服务器B,C接收到的IP被表示为服务器D而不是A的软件包.
  4. 编写自定义层来读取UDP的缺点是什么,然后形成一个TCP包,然后与负载均衡器保持TCP连接以转发该新形成的TCP包.在这种情况下,可以同时使用nginx或haproxy.

谢谢.

推荐答案

nginx在开源nginx(自v1.19.13起)和NGINX Plus中均支持UDP负载平衡.从nginx.com上阅读此帖子

nginx does support UDP load balancing in both open source nginx(since v1.19.13) and NGINX Plus. Read this post from nginx.com

并且nginx提供了基于ip_hash的UDP负载平衡,请检查文档

And nginx provides UDP load-balance based on ip_hash out of box,check the docs

所以我认为第二个问题的答案是肯定的.

So I think the answer to question No.2 is yes.

在文档此处中也提到过,nginx上游模块提供哈希自定义密钥上的算法,在您的情况下可能是MSG-ID,但是我不知道如何从UDP数据报中获取MSG-ID,我想这并不容易.我尝试搜索了一段时间,但没有运气.如果找到解决方案,希望您可以在此问题下分享.

Also mentioned in the docs here, nginx upstream module provide hash algorithm on a custom key, which in your case could be MSG-ID, but i don't know how you can get MSG-ID out from you UDP datagram and i guess it won't be easy. I tried to search for a while but got no luck. If you found a solution, hope you can share under this question.

这篇关于UDP负载平衡使用定制的平衡方法,并且在UDP主体内部具有会话ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆