# Nginx LoadBalancing to Logstash

**URL:** <https://discuss.elastic.co/t/nginx-loadbalancing-to-logstash/228177>\
**Category:** Logstash\
**Created:** [April 15, 2020, 5:21pm UTC](https://discuss.elastic.co/t/nginx-loadbalancing-to-logstash/228177 "2020-04-15T17:21:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![luiz.miguelsl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luiz.miguelsl/32/66382_2.png) [@luiz.miguelsl](https://discuss.elastic.co/u/luiz.miguelsl)\
**Post date:** [April 15, 2020, 5:21pm UTC](https://discuss.elastic.co/t/nginx-loadbalancing-to-logstash/228177/1 "2020-04-15T17:21:50Z")

</div>

Hi there guys, I hope you're all safe.

I have two Logstash instances behind an Nginx as the load balancer. The problem is that load balancing isn't happening properly. Always, one server is receiving more traffic than the other.

I tried least\_conn e round-robin on Nginx and both present the same results.

Here's my Nginx config:

```auto
           stream {
                upstream logstash {
                server server1:5044;
                server server2:5044;
                }

                server {
                listen endpoint_logstash:80;
                proxy_pass logstash;
                }
        }

```

As mentioned, I tried the default load-balancing method round-robin as well as least\_conn. Do you guys have any idea about what could I be missing? I think it could be related to the way Logstash persists TCP connections, but it's only a hunch.

Thanks

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [April 15, 2020, 5:54pm UTC](https://discuss.elastic.co/t/nginx-loadbalancing-to-logstash/228177/2 "2020-04-15T17:54:38Z")

</div>

A load balancer is typically balancing connections, not requests. If you have long-lived connections to logstash then unbalanced traffic would be normal.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 13, 2020, 5:54pm UTC](https://discuss.elastic.co/t/nginx-loadbalancing-to-logstash/228177/3 "2020-05-13T17:54:39Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
