auxdx
auxdx

Reputation: 2493

UDP load balancing using customised balancing method with session id inside UDP body

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 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?

I wish to know:

  1. What is best open-source solution to help me handle load-balance based on custom MSG-ID inside UDP body.
  2. Does nginx (free/open-source) version support at least UDP load-balance based on ip_hash method.
  3. Is there anyway I can spoof the UDP source/sender IP. Basically, if I have server (such as server A) which receive UDP package from multiple server (server D) and forward it to a set of server (server B, C); I want the server B, C receiving package with IP indicated as server D, not A.
  4. What is drawback of writing a custom layer which read UDP then form a TCP package and then maintain a TCP connection with load balancer to forward that newly-formed TCP package. In that case, both nginx or haproxy can be used.

Thanks.

Upvotes: 2

Views: 2396

Answers (2)

Dennis
Dennis

Reputation: 799

You would ordinarily use proxy_bind $remote_addr transparent; in your server {} context. Note that you need a (very) recent nginx with upstream / udp loadbalancing support for this to work.

Upvotes: 0

Hammer
Hammer

Reputation: 1582

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

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.

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.

Upvotes: 1

Related Questions