# \[LogStash\] how to intentionally slow down JDBC Input Plugin

**URL:** <https://discuss.elastic.co/t/logstash-how-to-intentionally-slow-down-jdbc-input-plugin/306979>\
**Category:** Logstash\
**Created:** [June 13, 2022, 2:24am UTC](https://discuss.elastic.co/t/logstash-how-to-intentionally-slow-down-jdbc-input-plugin/306979 "2022-06-13T02:24:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![JooHyukKim](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joohyukkim/32/106913_2.png) [@JooHyukKim](https://discuss.elastic.co/u/JooHyukKim)\
**Post date:** [June 13, 2022, 2:24am UTC](https://discuss.elastic.co/t/logstash-how-to-intentionally-slow-down-jdbc-input-plugin/306979/1 "2022-06-13T02:24:13Z")

</div>

## Table Of Contents

1. My situation
2. What I want
3. How I can help

### 1. my situation

1. I have to run logstash jdbc input against **Database** running in production.
2. I use pagination options to limit amount of data per query
3. but since SQL statements are run almost non-stop
4. **Database** metrics spike, affecting performance of other functionality
5. Slow down the logstash-input-jdbc queries

### 2. What I need: to slow down query to the database

#### My Imagination : Could be..... like this diagram below

anything to slow down the queries sent to the databse

 ![Screen Shot 2022-06-01 at 11 57 51 AM](https://us1.discourse-cdn.com/elastic/original/3X/0/e/0e5fca6b45c9d92d9cf6a823e948523f0b805c17.png)

---

<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:** [June 13, 2022, 3:40am UTC](https://discuss.elastic.co/t/logstash-how-to-intentionally-slow-down-jdbc-input-plugin/306979/2 "2022-06-13T03:40:24Z")

</div>

You could try using a [sleep](https://www.elastic.co/guide/en/logstash/current/plugins-filters-sleep.html) filter. By default there is an [in-memory queue](https://www.elastic.co/guide/en/logstash/current/memory-queue.html) between the input and the pipeline. If the queue fills up then the input stops reading data.

If you want to limit the rate at which the queue is drained (by each worker thread) to 1000 you could try

```
sleep { time => "0.001" }

```

(i.e. sleep for a millisecond per event). The event rate will drift around a number below 1000 per second.

Looking at [this](https://github.com/logstash-plugins/logstash-filter-sleep/blob/eb9fd10eb054d1234196572be20206ab445fdaf4/lib/logstash/filters/sleep.rb#L85) code, it suggests that

```
sleep { time => 0.001 }

```

would also work and be more efficient, but that would very much depend on how the [validation](https://github.com/logstash-plugins/logstash-filter-sleep/blob/eb9fd10eb054d1234196572be20206ab445fdaf4/lib/logstash/filters/sleep.rb#L27) works (it may do implicit coercion, it may not).

By limiting the rate at which events are removed from the queue you can limit the rate at which events are pulled from the database and added to the queue.

---

<div class="post-metadata">

**Author:** ![JooHyukKim](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joohyukkim/32/106913_2.png) [@JooHyukKim](https://discuss.elastic.co/u/JooHyukKim)\
**Post date:** [June 14, 2022, 1:37am UTC](https://discuss.elastic.co/t/logstash-how-to-intentionally-slow-down-jdbc-input-plugin/306979/3 "2022-06-14T01:37:01Z")

</div>

@Badger thank you for your solution.  
sounds like a plan!  
I will let you know how it turns out

---

<div class="post-metadata">

**Author:** ![JooHyukKim](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joohyukkim/32/106913_2.png) [@JooHyukKim](https://discuss.elastic.co/u/JooHyukKim)\
**Post date:** [June 14, 2022, 5:53am UTC](https://discuss.elastic.co/t/logstash-how-to-intentionally-slow-down-jdbc-input-plugin/306979/4 "2022-06-14T05:53:55Z")

</div>

@Badger it worked! thanks

---

<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:** [July 12, 2022, 5:54am UTC](https://discuss.elastic.co/t/logstash-how-to-intentionally-slow-down-jdbc-input-plugin/306979/5 "2022-07-12T05:54:08Z")

</div>

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