# Spark Connector performance issues - with start up time

**URL:** https://discuss.elastic.co/t/spark-connector-performance-issues-with-start-up-time/102634
**Category:** Elasticsearch
**Tags:** es-hadoop
**Created:** [October 4, 2017, 12:18am UTC](https://discuss.elastic.co/t/spark-connector-performance-issues-with-start-up-time/102634 "2017-10-04T00:18:07Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![tranan](https://avatars.discourse-cdn.com/v4/letter/t/a8b319/32.png) [@tranan](https://discuss.elastic.co/u/tranan)
#### Post date: [October 4, 2017, 12:18am UTC](https://discuss.elastic.co/t/spark-connector-performance-issues-with-start-up-time/102634/1 "2017-10-04T00:18:07Z")

</div>

I am currently experiencing performance issues where I notice that the Elasticsearch Spark connector is stuck 10's of minutes warming / starting up without any tasks / jobs allocated. See screen shot. Any idea on what is causing the 10's of minutes of warm up / startup time?

 ![ES](https://us1.discourse-cdn.com/elastic/original/3X/7/8/78abd1e9f5e6ca28c8483252795d58ba8a147098.PNG)

I have leverage both PySpark AND Spark Shell (Scala) and noticed the same issue

Here 's how I perform the query:

argusDF = sqlContext.read.format('org.elasticsearch.spark.sql')   
.option('es.resource', 'argus\*')   
.option('es.nodes', esCluster)   
.option('es.port', '9200')   
.option('pushdown', 'true')   
.option('es.scroll.keepalive', '2m')   
.option('es.http.timeout', '2m')   
.option('es.input.max.docs.per.partition', '10000')   
.option('es.scroll.size', '5000')   
.option('double.filtering', 'true')   
.option('es.index.read.missing.as.empty', 'true')   
.option('es.read.field.empty.as.null', 'true').load()  
argusTable = 'argus'  
argusDF.registerTempTable(argusTable)

sqlContext.sql('select ' + fieldsToQueryCSV + ' from ' + argusTable + ' where ' +   
'src\_ip= "'+ ipAddress + '" OR ' +   
'dest\_ip= "'+ ipAddress +'"')

---

<div class="post-metadata">

### Author: ![james.baiera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/james.baiera/32/10209_2.png) [@james.baiera](https://discuss.elastic.co/u/james.baiera)
#### Post date: [October 4, 2017, 3:50am UTC](https://discuss.elastic.co/t/spark-connector-performance-issues-with-start-up-time/102634/2 "2017-10-04T03:50:07Z")

</div>

@tranan - that's really peculiar. Are you able to get on to the Spark executor and collect a thread dump from the process using something like `jstack` and see what the process is stuck doing?

---

<div class="post-metadata">

### Author: ![tranan](https://avatars.discourse-cdn.com/v4/letter/t/a8b319/32.png) [@tranan](https://discuss.elastic.co/u/tranan)
#### Post date: [October 4, 2017, 10:01am UTC](https://discuss.elastic.co/t/spark-connector-performance-issues-with-start-up-time/102634/3 "2017-10-04T10:01:15Z")

</div>

Attached is a screenshot from the executor tab. Note that there are a number of executors and cores that are live but no tasks.

 ![ThreadDump](https://us1.discourse-cdn.com/elastic/original/3X/a/1/a140bb75e55e9d2637b9e300ce5e9d4063f7366f.PNG)

Secondly I have clicked the thread dump link on one of the live executor and see the thread dump screenshot below. This is similar for all the live executors

 ![dump1](https://us1.discourse-cdn.com/elastic/original/3X/7/e/7e4782eb98fa5da5fb0c78482f9009da2ab6ac09.PNG) ![dump3](https://us1.discourse-cdn.com/elastic/original/3X/9/d/9d97b1a5c3d37cfdc3a9c7ec0ede18b17a9ef8db.PNG) ![dump2](https://us1.discourse-cdn.com/elastic/original/3X/0/6/062bb0ea178602e5c049704fb42edb6739cbdb6d.PNG)

Please note this is running on YARN. I have also reproduce this issue on another cluster running Spark Standalone pointing to the same Elasticsearch cluster. Also i want to note that the the regular REST and Java API works perfectly.

---

<div class="post-metadata">

### Author: ![james.baiera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/james.baiera/32/10209_2.png) [@james.baiera](https://discuss.elastic.co/u/james.baiera)
#### Post date: [October 4, 2017, 1:17pm UTC](https://discuss.elastic.co/t/spark-connector-performance-issues-with-start-up-time/102634/4 "2017-10-04T13:17:53Z")

</div>

It seems the cluster is totally idle, waiting for work to be assigned. Would you be able to pull a thread dump from your Spark driver to see what it might be stuck doing that is keeping it from assigning work?

---

<div class="post-metadata">

### Author: ![tranan](https://avatars.discourse-cdn.com/v4/letter/t/a8b319/32.png) [@tranan](https://discuss.elastic.co/u/tranan)
#### Post date: [October 4, 2017, 6:47pm UTC](https://discuss.elastic.co/t/spark-connector-performance-issues-with-start-up-time/102634/5 "2017-10-04T18:47:57Z")

</div>

Below is the thread dump of the driver... I suspect the cluster is trying to get a file handle on all the shards that are in the cluster and blocking until it can. There's a total of ~3300 shards in the cluster ~ 30TB of data. I also noticed if i change the http timeout duration say to \< 1M i get timeout exception.

 ![driverdump2](https://us1.discourse-cdn.com/elastic/original/3X/7/4/74afca8fd8255e5136c93dec5d73e3e8c947b1db.PNG) ![driverdump1](https://us1.discourse-cdn.com/elastic/original/3X/3/4/345bc4ca881cf669d5f3fe60665699b489de10da.PNG)

---

<div class="post-metadata">

### Author: ![james.baiera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/james.baiera/32/10209_2.png) [@james.baiera](https://discuss.elastic.co/u/james.baiera)
#### Post date: [October 5, 2017, 5:17pm UTC](https://discuss.elastic.co/t/spark-connector-performance-issues-with-start-up-time/102634/6 "2017-10-05T17:17:20Z")

</div>

I'm not sure I see any ES-Hadoop related classes in those thread dumps. ES-Hadoop does create at least one Spark partition for each shard in the indices that it wants to read from. It's possible that Spark is having a hard time handling that many partitions during its startup phase.

---

<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: [November 2, 2017, 5:18pm UTC](https://discuss.elastic.co/t/spark-connector-performance-issues-with-start-up-time/102634/7 "2017-11-02T17:18:00Z")

</div>

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