# TCP Input - behaviour under load

**URL:** <https://discuss.elastic.co/t/tcp-input-behaviour-under-load/158913>\
**Category:** Logstash\
**Created:** [November 30, 2018, 2:28pm UTC](https://discuss.elastic.co/t/tcp-input-behaviour-under-load/158913 "2018-11-30T14:28:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulkeogh](https://avatars.discourse-cdn.com/v4/letter/p/8dc957/32.png) [@paulkeogh](https://discuss.elastic.co/u/paulkeogh)\
**Post date:** [November 30, 2018, 2:28pm UTC](https://discuss.elastic.co/t/tcp-input-behaviour-under-load/158913/1 "2018-11-30T14:28:09Z")

</div>

I was looking at the method in the TCP input plugin that enqueues incoming documents onto the output queue.

```
def enqueue_decorated(event, client_ip_address, client_address, client_port, socket)
event.set(HOST_FIELD, client_address) unless event.get(HOST_FIELD)
event.set(HOST_IP_FIELD, client_ip_address) unless event.get(HOST_IP_FIELD)
event.set(PORT_FIELD, client_port) unless event.get(PORT_FIELD)
event.set(SSLSUBJECT_FIELD, socket.peer_cert.subject.to_s) if socket && @ssl_enable && @ssl_verify && event.get(SSLSUBJECT_FIELD).nil?
decorate(event)
@output_queue << event

```

end

What happens if output\_queue is full and the \<\< operator fails ? Does the TCP client get any notification ?

---

<div class="post-metadata">

**Author:** ![yaauie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yaauie/32/23363_2.png) [@yaauie](https://discuss.elastic.co/u/yaauie)\
**Post date:** [November 30, 2018, 5:57pm UTC](https://discuss.elastic.co/t/tcp-input-behaviour-under-load/158913/2 "2018-11-30T17:57:16Z")

</div>

Both queue implementations that ship with Logstash (memory and persistent) will block the input's thread when an event is pushed onto the queue and the queue does not have capacity, until such a time as the event has been added to the queue. In the TCP input's case, once the thread is blocked, it will stop reading from the socket, applying back-pressure to the sender at the protocol level.

---

<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:** [December 28, 2018, 5:57pm UTC](https://discuss.elastic.co/t/tcp-input-behaviour-under-load/158913/3 "2018-12-28T17:57:19Z")

</div>

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