# Rate limiting between Filebeat and Logstash?

**URL:** <https://discuss.elastic.co/t/rate-limiting-between-filebeat-and-logstash/95377>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [August 1, 2017, 4:20pm UTC](https://discuss.elastic.co/t/rate-limiting-between-filebeat-and-logstash/95377 "2017-08-01T16:20:21Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![DravenJohnson](https://avatars.discourse-cdn.com/v4/letter/d/839c29/32.png) [@DravenJohnson](https://discuss.elastic.co/u/DravenJohnson)\
**Post date:** [August 1, 2017, 4:20pm UTC](https://discuss.elastic.co/t/rate-limiting-between-filebeat-and-logstash/95377/1 "2017-08-01T16:20:22Z")

</div>

If there any rate limiting between filebeat and logstash?  
or some kind of back pressure setting that between filebeat and logstash?

We have ~2K server running filebeat and input logs to (12) logstash by using the beat plugin.  
At some time during the day, few (usually ~15 now ~40) hosts start slow down the data transport speed and start lagging reporting to logstash.

Seem to us, that either logstash or the client filebeat installed is overloaded or network bandwidth limit this. Restart filebeat which allow it pick up another logstash host usually fix the problem

any idea?

---

<div class="post-metadata">

**Author:** ![abhiroyg](https://avatars.discourse-cdn.com/v4/letter/a/e9bcb4/32.png) [@abhiroyg](https://discuss.elastic.co/u/abhiroyg)\
**Post date:** [August 2, 2017, 9:46am UTC](https://discuss.elastic.co/t/rate-limiting-between-filebeat-and-logstash/95377/2 "2017-08-02T09:46:58Z")

</div>

Hi,

I can only confirm part of your question. Back pressure exists between logstash and filebeat. Please refer to this link: [https://www.elastic.co/guide/en/logstash/current/persistent-queues.html#backpressure-persistent-queue](https://www.elastic.co/guide/en/logstash/current/persistent-queues.html#backpressure-persistent-queue)

Hope it helps

---

<div class="post-metadata">

**Author:** ![steffens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steffens/32/79630_2.png) [@steffens](https://discuss.elastic.co/u/steffens)\
**Post date:** [August 2, 2017, 7:24pm UTC](https://discuss.elastic.co/t/rate-limiting-between-filebeat-and-logstash/95377/3 "2017-08-02T19:24:49Z")

</div>

Can you share filebeat configuration and logs?

---

<div class="post-metadata">

**Author:** ![DravenJohnson](https://avatars.discourse-cdn.com/v4/letter/d/839c29/32.png) [@DravenJohnson](https://discuss.elastic.co/u/DravenJohnson)\
**Post date:** [August 2, 2017, 7:49pm UTC](https://discuss.elastic.co/t/rate-limiting-between-filebeat-and-logstash/95377/4 "2017-08-02T19:49:25Z")

</div>

> <https://gist.github.com/DravenJohnson/80843832dca33bbf66761c8463d70579>

We don't enable the logging for filebeat, sorry.

It's really hard to reproduce this situation since you have to have certain amount of filebeat / servers in order to see that. It must be something to do with back pressure.

---

<div class="post-metadata">

**Author:** ![DravenJohnson](https://avatars.discourse-cdn.com/v4/letter/d/839c29/32.png) [@DravenJohnson](https://discuss.elastic.co/u/DravenJohnson)\
**Post date:** [August 4, 2017, 3:14pm UTC](https://discuss.elastic.co/t/rate-limiting-between-filebeat-and-logstash/95377/5 "2017-08-04T15:14:43Z")

</div>

Any update on this?

---

<div class="post-metadata">

**Author:** ![steffens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steffens/32/79630_2.png) [@steffens](https://discuss.elastic.co/u/steffens)\
**Post date:** [August 7, 2017, 1:17pm UTC](https://discuss.elastic.co/t/rate-limiting-between-filebeat-and-logstash/95377/6 "2017-08-07T13:17:23Z")

</div>

I don't see anything special in your configs. The connection between filebeat -\> logstash uses TCP. Plus filebeat waits for ACK from logstash, to update the registry and free resources of published log messages. If no ACK is received, filebeat has to assume a network/logstash failure and send events. Any system using TCP for pushing messages/events is subject to back-pressure.  
Second to TCP and ACK, filebeat also applies some 'windowing', which starts at 10 events and exponentially grows up to `bulk_max_size`. If logstash is overloaded and we see errors/disconnects, the window can shrink and at some point even get stalled at a not that optimum value. This is to ensure beats don't break/kill older versions of Logstash, not sending some health-ping. But the window size can only be inspected via debug logs (`-d 'logstash'`).

Logstash internally uses queues and pushes data to Elasticsearch (or other services), mostly via TCP and Request-Response like protocols (HTTP). That is, the outputs, network and Logstash filters can contribute to the overall back-pressure experienced by filebeat. Sometimes it's a 'bad' log messages `grok` has to grind upon (consider `dissect` filter if you find `grok` to be slow).

Networking can play a big role during peek times, as bandwidth might be shared with the others application bandwidth requirements (plus QoS settings?), potentially affecting the TCP connections throughput. Add things like bufferbloat in network devices/OS and buffered TCP segments being resend + increases latencies negating TCP congestion control can negatively impact throughput.

A simple technique to relief a system from `temporal` overload/back-pressure is buffering in intermediate queues. That's one use-case for the persistent-queue in Logstash, as the queue can accept/ACK events, if if filters/outputs can not keep up. Still, when using queues, they should operate in almost-empty-state all the time. If you find your queues to be full for much to long time, the buffering effect is mostly neutralised for no good.

You can test filebeat-\>file/console output, to get an idea how fast filebeat can process your logs. Normally network outputs add some more overhead (e.g. compression for LS output, network, decompression, decoding in LS, ...), getting you some more back-pressure in filebeat.

In 6.0beta1 we introduce asynchronous sending of events + pipelining of batches by default. Pipelining can reduce network/encoding/decoding latencies, potentially increasing throughput.

How many logstash instances are you running in your system. If you already have multiple instances, you might consider to:

- use load-balancing of all beats to all logstash instances
- configure all logstash instances in all beats without load balancing.

In the later case, filebeat will connect to one logstash instance by random. On I/O error, filebeat will reconnect to another Logstash instance by random. But if filebeat is only slowed down (without I/O error), it will not try to reconnect.

---

<div class="post-metadata">

**Author:** ![DravenJohnson](https://avatars.discourse-cdn.com/v4/letter/d/839c29/32.png) [@DravenJohnson](https://discuss.elastic.co/u/DravenJohnson)\
**Post date:** [August 9, 2017, 4:58pm UTC](https://discuss.elastic.co/t/rate-limiting-between-filebeat-and-logstash/95377/7 "2017-08-09T16:58:28Z")

</div>

Thank you so much for this awesome answer.

We have ~12 instances. we had some bad experience with ELB (AWS's load-balancer) so we stop using it. (It had same problem as now so ELB won't help)

Right now we try to use DNS round-robin.

It might be network problem that cause this, but we want to know which part, why and how to fix this.  
The most lagging hosts (there are ~20 now each day, some time same some time different) lag for ~ 2-10 hours and it mostly from hosts that in far region such as Japan, Indian etc. (Our Elk is on AWS in US-East region). On these hosts, filebeat still sending logs, just at really slow speed and have a lot of files been hold back. Restart filebeat usually allow it pick up another logastash instance and then eventually caught up all logs in ~ 10 min.

We will do more testing on this now but we also want to understand more about how filebeat -\> logsatsh limit speed / rate based on Load and Network performance.

Thanks again.

---

<div class="post-metadata">

**Author:** ![steffens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steffens/32/79630_2.png) [@steffens](https://discuss.elastic.co/u/steffens)\
**Post date:** [August 10, 2017, 1:07pm UTC](https://discuss.elastic.co/t/rate-limiting-between-filebeat-and-logstash/95377/8 "2017-08-10T13:07:25Z")

</div>

Well, sending logs from Asias to US is quite a distance. Plus, I think AWS applies TCP rate limiting as well.

Some more input on deployment patterns also check:

- [https://www.elastic.co/blog/clustering\_across\_multiple\_data\_centers](https://www.elastic.co/blog/clustering_across_multiple_data_centers)
- (look for header "Multi Data Centers with a Queue at Each DC"): [https://www.elastic.co/blog/small-medium-or-large-scaling-elasticsearch-and-evolving-the-elastic-stack-to-fit](https://www.elastic.co/blog/small-medium-or-large-scaling-elasticsearch-and-evolving-the-elastic-stack-to-fit)

---

<div class="post-metadata">

**Author:** ![DravenJohnson](https://avatars.discourse-cdn.com/v4/letter/d/839c29/32.png) [@DravenJohnson](https://discuss.elastic.co/u/DravenJohnson)\
**Post date:** [August 16, 2017, 6:56pm UTC](https://discuss.elastic.co/t/rate-limiting-between-filebeat-and-logstash/95377/9 "2017-08-16T18:56:51Z")

</div>

Thank you so much for this great answer.

For now, we are doing a bunch of investigation and seem like problem exist, pretty sure it's some kind of rate limiting issue.

I am wondering if the script that use to get filebeat rate no longer works? [Filebeat sending data to Logstash seems too slow](https://discuss.elastic.co/t/filebeat-sending-data-to-logstash-seems-too-slow/37596/13)  
Is there any other solution to test the filebeat and logstash rate?

---

<div class="post-metadata">

**Author:** ![steffens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steffens/32/79630_2.png) [@steffens](https://discuss.elastic.co/u/steffens)\
**Post date:** [August 17, 2017, 9:27pm UTC](https://discuss.elastic.co/t/rate-limiting-between-filebeat-and-logstash/95377/10 "2017-08-17T21:27:38Z")

</div>

I haven't used the script in a while, but it should still work. Well, as we have many more variables now, the script might break if the terminal is not big enough...

filebeat reports non-zero metrics to it's logs about every 30 seconds. Actually it reports the delta. If you look for acked\_events and divide it by 30s you get the rate. Plus logstash also collects internal metrics one can already use with x-pack monitoring.

For testing filebeat-\>logstash throughput without filters one can use this logstash configuration:

```auto
input {
  beats { ... }
}

output {
  stdout { codec => "dots" }
}

```

This prints a `.` per event being processed by logstash. Running logstash with `logstash -f test.conf | pv -War >/dev/null`you can see the current and average event rate in your terminal. As this test removes filters, outputs and any kind of additional source for back-pressure, this gets you a quite good base number on event rates you can actually send to logstash in your environment. This way you can also see how additional filebeat instances might affect overall throughput (which should not scale linearly, due to additional contention).

---

<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:** [September 14, 2017, 9:27pm UTC](https://discuss.elastic.co/t/rate-limiting-between-filebeat-and-logstash/95377/11 "2017-09-14T21:27:42Z")

</div>

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