# 'took' time fast, curl sometimes slow

**URL:** <https://discuss.elastic.co/t/took-time-fast-curl-sometimes-slow/353422>\
**Category:** Elasticsearch\
**Created:** [February 16, 2024, 12:56am UTC](https://discuss.elastic.co/t/took-time-fast-curl-sometimes-slow/353422 "2024-02-16T00:56:10Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryans](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@ryans](https://discuss.elastic.co/u/ryans)\
**Post date:** [February 16, 2024, 12:56am UTC](https://discuss.elastic.co/t/took-time-fast-curl-sometimes-slow/353422/1 "2024-02-16T00:56:10Z")

</div>

I am using Elastic Cloud for my Elasticsearch instance. My issue is that sometimes (rarely) I'm seeing strange behavior where the curl time (round trip from my web server to Elastic Cloud) is taking 8+ seconds but the 'took' time in the response is approx. 45ms. It's not the same query every time and doesn't happen often (maybe once or twice a day out of millions of queries). Every time I run the query manually, it's super fast and the Profiler says it looks good.

This is the typical behavior, but about every 5 days, I get a spraying of these where it happens to every query I'm sending to Elastic at the same time. So I end up with about 50-60 queries that are slow in curl time but fast in 'took' time. I do an auto-retry and they work just fine.

My network guy has looked and said we are seeing 0 return packets, not even completing the 3-way handshake from the Elastic Cloud during these spraying events. We have a huge pipe and have no other network events at these times.

Does anyone have any ideas?

This sounds like the web server handling the API requests for Elasticsearch is getting overloaded, but I don't know all the pieces in the stack.

How can 'took' be fast and curl be slow?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [February 16, 2024, 1:13am UTC](https://discuss.elastic.co/t/took-time-fast-curl-sometimes-slow/353422/2 "2024-02-16T01:13:37Z")

</div>

Hi @ryans

`took` is the actual query time within elasticsearch ... The time it took to execute the query in elasticsearch once elasticsearch receives the query and the is ready to return the results

.. it is not the roundtrip http request / response time.

> [@ryans](#):
>
> How can 'took' be fast and curl be slow?

So with the above explanation there are many reasons why curl can take longer.. unfortunately it is my experience that intermittent network delays can be difficult to catch / diagnose

And that is not to say it may be all on your side .. in Elastic Cloud there are some components between the your Elasticsearch Cluster.

There is an Edge Proxy...

But that said if we were have repeated issues I suspect we would be getting a number of alerts / calls...

---

<div class="post-metadata">

**Author:** ![ryans](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@ryans](https://discuss.elastic.co/u/ryans)\
**Post date:** [February 16, 2024, 3:27pm UTC](https://discuss.elastic.co/t/took-time-fast-curl-sometimes-slow/353422/3 "2024-02-16T15:27:04Z")

</div>

Thanks for the response. That was my understanding of what 'took' is, which is why I posted my predicament here.  
My network guys says "not us", so I'm just trying to figure out the pieces in between the time that 'took' is calculated and the internet. You mentioned the Edge Proxy. Is there anything else?

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [February 16, 2024, 3:33pm UTC](https://discuss.elastic.co/t/took-time-fast-curl-sometimes-slow/353422/4 "2024-02-16T15:33:54Z")

</div>

> [@ryans](#):
>
> My network guys says "not us",

🙂

Do a traceroute and look at all the hops in between... could be any of them...  
Intermittent Networking debugging... super hard....

If you can repeat it ... OR you have captured it Support can look on our Side up to our Edge... but there is a lot in between I suspect.

---

<div class="post-metadata">

**Author:** ![ryans](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@ryans](https://discuss.elastic.co/u/ryans)\
**Post date:** [February 16, 2024, 9:08pm UTC](https://discuss.elastic.co/t/took-time-fast-curl-sometimes-slow/353422/5 "2024-02-16T21:08:05Z")

</div>

Thanks. Do you know of any pieces within the Elastic Cloud stack that could be investigated after the 'took' time is calculated?

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [February 16, 2024, 9:56pm UTC](https://discuss.elastic.co/t/took-time-fast-curl-sometimes-slow/353422/6 "2024-02-16T21:56:50Z")

</div>

Like I said there is only one component that I ever really looked at... That's the proxy sits in front... But that is highly highly monitored as all our customer traffic passes through those (there are many distributed ) If there's any latency issues the team is usually directly on it.

---

<div class="post-metadata">

**Author:** ![ryans](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@ryans](https://discuss.elastic.co/u/ryans)\
**Post date:** [February 19, 2024, 1:59pm UTC](https://discuss.elastic.co/t/took-time-fast-curl-sometimes-slow/353422/7 "2024-02-19T13:59:04Z")

</div>

Thanks. I thought you knew of some others based on your previous reply.

---

<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:** [March 18, 2024, 1:59pm UTC](https://discuss.elastic.co/t/took-time-fast-curl-sometimes-slow/353422/8 "2024-03-18T13:59:12Z")

</div>

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