# Udp balancing

**URL:** <https://www.ruby-forum.com/t/udp-balancing/244844>\
**Category:** NGINX\
**Created:** [June 23, 2016, 5:45pm UTC](https://www.ruby-forum.com/t/udp-balancing/244844 "2016-06-23T17:45:20Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sadaf\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@Sadaf\_N](https://www.ruby-forum.com/u/Sadaf_N)\
**Post date:** [June 23, 2016, 5:45pm UTC](https://www.ruby-forum.com/t/udp-balancing/244844/1 "2016-06-23T17:45:20Z")

</div>

Hi,

In the default stream/udp/proxy setup, will nginx round robin every  
packet  
or will it remembers client and send all packets from same client to  
same  
upstream?

Thanks  
Frank

---

<div class="post-metadata">

**Author:** ![fjlj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e79b87/32.png) [@fjlj](https://www.ruby-forum.com/u/fjlj)\
**Post date:** [June 23, 2016, 5:48pm UTC](https://www.ruby-forum.com/t/udp-balancing/244844/2 "2016-06-23T17:48:50Z")

</div>

On 6/23/16 6:44 PM, Frank L. wrote:

> Hi,
> 
> In the default stream/udp/proxy setup, will nginx round robin every  
> packet or will it remembers client and send all packets from same  
> client to same upstream?

The default is round-robin, yes.

You can enable persistent-like behaviour though:

> **[F5 NGINX: Built for cloud-native apps. Ready for AI traffic.](https://www.f5.com/products/nginx)**
>
> Deliver modern applications with NGINX. Explore high-performance load balancing, API gateways, and web server solutions trusted by top global enterprises.

–  
Maxim K.

---

<div class="post-metadata">

**Author:** ![fjlj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e79b87/32.png) [@fjlj](https://www.ruby-forum.com/u/fjlj)\
**Post date:** [June 23, 2016, 5:57pm UTC](https://www.ruby-forum.com/t/udp-balancing/244844/3 "2016-06-23T17:57:36Z")

</div>

That makes sense for udp (connection less).  
What about tcp? I assume when client initiate the connection , nginx  
will  
pick one upstream (rr) to make a connection and send all subsequent  
packets  
to the same upstream using the same connection.

Frank

---

<div class="post-metadata">

**Author:** ![fjlj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e79b87/32.png) [@fjlj](https://www.ruby-forum.com/u/fjlj)\
**Post date:** [June 23, 2016, 6:08pm UTC](https://www.ruby-forum.com/t/udp-balancing/244844/4 "2016-06-23T18:08:42Z")

</div>

On 6/23/16 6:57 PM, Frank L. wrote:

> That makes sense for udp (connection less).  
> What about tcp? I assume when client initiate the connection , nginx  
> will pick one upstream (rr) to make a connection and send all  
> subsequent packets to the same upstream using the same connection.

Not sure I understand your request.

For tcp nginx balances new connections based on the configured load  
balancing discipline (rr by default).

> ```
> > packet or will it remembers client and send all packets from same
> 
> ```
> 
> [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)

–  
Maxim K.

---

<div class="post-metadata">

**Author:** ![fjlj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e79b87/32.png) [@fjlj](https://www.ruby-forum.com/u/fjlj)\
**Post date:** [June 23, 2016, 7:08pm UTC](https://www.ruby-forum.com/t/udp-balancing/244844/5 "2016-06-23T19:08:53Z")

</div>

To summarize:  
TCP balancing decision is on every new connection.  
TCP balancing decision is on every packet since it is connectionless.

---

<div class="post-metadata">

**Author:** ![fjlj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e79b87/32.png) [@fjlj](https://www.ruby-forum.com/u/fjlj)\
**Post date:** [June 23, 2016, 6:20pm UTC](https://www.ruby-forum.com/t/udp-balancing/244844/6 "2016-06-23T18:20:23Z")

</div>

On Thursday 23 June 2016 08:57:22 Frank L. wrote:

> That makes sense for udp (connection less).  
> What about tcp? I assume when client initiate the connection , nginx will  
> pick one upstream (rr) to make a connection and send all subsequent packets  
> to the same upstream using the same connection.

Right.

wbr, Valentin V. Bartenev

---

<div class="post-metadata">

**Author:** ![fjlj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e79b87/32.png) [@fjlj](https://www.ruby-forum.com/u/fjlj)\
**Post date:** [June 23, 2016, 7:43pm UTC](https://www.ruby-forum.com/t/udp-balancing/244844/7 "2016-06-23T19:43:21Z")

</div>

* * *

nginx mailing list  
removed\_email\_address@domain.invalid  
[http://mailman.nginx.org/mailman/listinfo/nginx](http://mailman.nginx.org/mailman/listinfo/nginx)

---

<div class="post-metadata">

**Author:** ![fjlj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e79b87/32.png) [@fjlj](https://www.ruby-forum.com/u/fjlj)\
**Post date:** [June 23, 2016, 8:59pm UTC](https://www.ruby-forum.com/t/udp-balancing/244844/8 "2016-06-23T20:59:17Z")

</div>

Yes, thanks 🙂

On Thu, Jun 23, 2016 at 10:42 AM, Pratyush Kumar  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
