# Intake very slow (more than 10secondes)

**URL:** <https://discuss.elastic.co/t/intake-very-slow-more-than-10secondes/269558>\
**Category:** APM\
**Tags:** server\
**Created:** [April 8, 2021, 7:13am UTC](https://discuss.elastic.co/t/intake-very-slow-more-than-10secondes/269558 "2021-04-08T07:13:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ebuildy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ebuildy/32/6070_2.png) [@ebuildy](https://discuss.elastic.co/u/ebuildy)\
**Post date:** [April 8, 2021, 7:13am UTC](https://discuss.elastic.co/t/intake-very-slow-more-than-10secondes/269558/1 "2021-04-08T07:13:56Z")

</div>

**Elastic stack version** 7.12.0 with Platinium licence

**APM Agent language and version** : nodeJS - 3.X (latest)

Run on k8s.

Our nodeJS application complains about timeout when sending APM events to intake API. I setup instrumentation on apm-server, and see `POST /intake/v2/events` can take more than 10s!

 ![Capture d’écran 2021-04-08 à 08.55.03](https://us1.discourse-cdn.com/elastic/original/3X/2/a/2aa57954c4fa13cabcdaa8f27d4b981f9122b334.jpeg)

I dont see any trouble on ES cluster, thread pools are fine.

Our apm-server.yml config file:

> <https://gist.github.com/ebuildy/119beca1063f3915201bd62e5b821276>

In APM-server logs, I can see sometimes "queue is full".

We use "stack monitoring", on an extra ES cluster:

 ![Capture d’écran 2021-04-08 à 09.13.16](https://us1.discourse-cdn.com/elastic/original/3X/d/0/d0c7a57ee8c0fda8951d34444010c1dc0be86c45.jpeg)

I am not an expert on APM-server (yet!) , but I was thinking intake API should be very fast, with a queue system between in and output?

I suspect long GC:

 ![Capture d’écran 2021-04-08 à 10.28.52](https://us1.discourse-cdn.com/elastic/original/3X/f/f/ff4d156de920342490794bdb7a41a6964e2925cf.png)

---

<div class="post-metadata">

**Author:** ![trentm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/trentm/32/77647_2.png) [@trentm](https://discuss.elastic.co/u/trentm)\
**Post date:** [April 8, 2021, 3:15pm UTC](https://discuss.elastic.co/t/intake-very-slow-more-than-10secondes/269558/2 "2021-04-08T15:15:13Z")

</div>

@ebuildy Hi! I don't know for sure from your data, but it is possible this is due to an issue in the Node.js APM agent: [Blocking Behavior under Benchmarking Load · Issue #136 · elastic/apm-nodejs-http-client · GitHub](https://github.com/elastic/apm-nodejs-http-client/issues/136)  
That issue is "fixed", but is not yet in a released APM agent. The work to get it into an APM agent release is here: [fix: blocking behaviour under load by trentm · Pull Request #2024 · elastic/apm-agent-nodejs · GitHub](https://github.com/elastic/apm-agent-nodejs/pull/2024)

This Node.js APM agent issue can happen when the app using the agent is under fairly high load and/or the APM server is being slow or non-responsive. If possible, you _could_ try this branch of the APM agent to see if that helps: [GitHub - elastic/apm-agent-nodejs at trentm/blocking-behavior](https://github.com/elastic/apm-agent-nodejs/tree/trentm/blocking-behavior)

I don't know apm-server that well, so I don't know if there could also be a server-side issue here. Seeing "queue is full" is the apm-server logs suggests that yes, there might be.

---

<div class="post-metadata">

**Author:** ![trentm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/trentm/32/77647_2.png) [@trentm](https://discuss.elastic.co/u/trentm)\
**Post date:** [April 8, 2021, 3:17pm UTC](https://discuss.elastic.co/t/intake-very-slow-more-than-10secondes/269558/3 "2021-04-08T15:17:44Z")

</div>

> [@ebuildy](#):
>
> see `POST /intake/v2/events` can take more than 10s!

Those requests taking 10s might be normal behaviour. They are long-running requests that an APM agent can keep open while sending up data with a chunked-encoding. The agent's `apiRequestTime` ([Configuration options | APM Node.js Agent Reference [4.x] | Elastic](https://www.elastic.co/guide/en/apm/agent/nodejs/current/configuration.html#api-request-time)) config var defaults to 10s. That is the time after which it will close an intake request to the APM server and start a new one.

---

<div class="post-metadata">

**Author:** ![ebuildy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ebuildy/32/6070_2.png) [@ebuildy](https://discuss.elastic.co/u/ebuildy)\
**Post date:** [April 8, 2021, 3:42pm UTC](https://discuss.elastic.co/t/intake-very-slow-more-than-10secondes/269558/4 "2021-04-08T15:42:38Z")

</div>

Ho, ok , didnt know about long live connection.

So nodeJS agent settings `serverTimeout` must be \> `apiRequestTime` , ok I got it !

---

<div class="post-metadata">

**Author:** ![trentm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/trentm/32/77647_2.png) [@trentm](https://discuss.elastic.co/u/trentm)\
**Post date:** [April 8, 2021, 4:21pm UTC](https://discuss.elastic.co/t/intake-very-slow-more-than-10secondes/269558/5 "2021-04-08T16:21:29Z")

</div>

> [@ebuildy](#):
>
> So nodeJS agent settings `serverTimeout` must be \> `apiRequestTime` , ok I got it !

That is the best practice yes. It is slightly more subtle: the `serverTimeout` is a timeout on _socket inactivity_, so it will get reset if there is any data being sent through (like APM transactions or spans, or the agent's regular metricsets reporting). Also the agent is gzip'ing the data it sends so there is some buffering happening there as well.

---

<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:** [April 29, 2021, 12:22pm UTC](https://discuss.elastic.co/t/intake-very-slow-more-than-10secondes/269558/6 "2021-04-29T12:22:17Z")

</div>

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