# Thread waitedTime is more while connecting to elastic

**URL:** <https://discuss.elastic.co/t/thread-waitedtime-is-more-while-connecting-to-elastic/264024>\
**Category:** Elasticsearch\
**Created:** [February 11, 2021, 2:05pm UTC](https://discuss.elastic.co/t/thread-waitedtime-is-more-while-connecting-to-elastic/264024 "2021-02-11T14:05:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sumaiya](https://avatars.discourse-cdn.com/v4/letter/s/a6a055/32.png) [@Sumaiya](https://discuss.elastic.co/u/Sumaiya)\
**Post date:** [February 11, 2021, 2:05pm UTC](https://discuss.elastic.co/t/thread-waitedtime-is-more-while-connecting-to-elastic/264024/1 "2021-02-11T14:05:35Z")

</div>

Hello All ,

One of our spring boot micro service connecting to elastic has high response time , while the took time itself is 50ms the service response time is high . After taking couple of threaddumps I see there are in total 10 threads in each dump and 1 or 2 out of 10 threads are in RUNNABLE status always and remaining threads are either in WATING or TIMED\_WATING. The below thread says waitedTime after thread contention monitoring was enable and it shows waitedTime": 4985607ms .

1. What should be my starting point for analysis?
2. What could cause these threads to wait for so long ?

Appreciate your help on this .

**2 threads has this status**

`

{  
"threadName": "http-nio-8080-exec-12",  
"threadId": 37,  
"blockedTime": 0,  
"blockedCount": 0,  
"waitedTime": 4985607,  
"waitedCount": 1245,  
"lockName": null,  
"lockOwnerId": -1,  
"lockOwnerName": null,  
"inNative": false,  
"suspended": false,  
"threadState": "RUNNABLE",  
"stackTrace": [  
{  
"methodName": "dumpThreads0",  
"fileName": "ThreadImpl.java",  
"lineNumber": -2,  
"className": "sun.management.ThreadImpl",  
"nativeMethod": true  
},  
{  
"methodName": "dumpAllThreads",  
"fileName": "ThreadImpl.java",  
"lineNumber": 454,  
"className": "sun.management.ThreadImpl",  
"nativeMethod": false  
},  
{  
"methodName": "invoke",  
"fileName": "DumpEndpoint.java",  
"lineNumber": 44,  
"className": "org.springframework.boot.actuate.endpoint.DumpEndpoint",  
"nativeMethod": false  
},  
{  
"methodName": "invoke",  
"fileName": "DumpEndpoint.java",  
"lineNumber": 31,  
"className": "org.springframework.boot.actuate.endpoint.DumpEndpoint",  
"nativeMethod": false  
},

`  
_ **8 threads have this status** _

{  
"threadName": "http-nio-8080-exec-14",  
"threadId": 67,  
"blockedTime": 0,  
"blockedCount": 0,  
"waitedTime": 4756546,  
"waitedCount": 1248,  
"lockName": null,  
"lockOwnerId": -1,  
"lockOwnerName": null,  
"inNative": false,  
"suspended": false,  
"threadState": "RUNNABLE",  
"stackTrace": [  
{  
"methodName": "dumpThreads0",  
"fileName": "ThreadImpl.java",  
"lineNumber": -2,  
"className": "sun.management.ThreadImpl",  
"nativeMethod": true  
},  
{  
"methodName": "dumpAllThreads",  
"fileName": "ThreadImpl.java",  
"lineNumber": 454,  
"className": "sun.management.ThreadImpl",  
"nativeMethod": false  
},  
{  
"methodName": "invoke",  
"fileName": "DumpEndpoint.java",  
"lineNumber": 44,  
"className": "org.springframework.boot.actuate.endpoint.DumpEndpoint",  
"nativeMethod": false  
},  
{  
"methodName": "invoke",  
"fileName": "DumpEndpoint.java",  
"lineNumber": 31,  
"className": "org.springframework.boot.actuate.endpoint.DumpEndpoint",  
"nativeMethod": false

---

<div class="post-metadata">

**Author:** ![Sumaiya](https://avatars.discourse-cdn.com/v4/letter/s/a6a055/32.png) [@Sumaiya](https://discuss.elastic.co/u/Sumaiya)\
**Post date:** [February 12, 2021, 12:59am UTC](https://discuss.elastic.co/t/thread-waitedtime-is-more-while-connecting-to-elastic/264024/2 "2021-02-12T00:59:04Z")

</div>

I did profiling of my client code which is calling elastic . Most of time is spent on Class CountDownLatch

---

<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 12, 2021, 12:59am UTC](https://discuss.elastic.co/t/thread-waitedtime-is-more-while-connecting-to-elastic/264024/3 "2021-03-12T00:59:54Z")

</div>

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