# Initializing\_shards - second db start up takes long time

**URL:** <https://discuss.elastic.co/t/initializing-shards-second-db-start-up-takes-long-time/28357>\
**Category:** Elasticsearch\
**Created:** [August 31, 2015, 1:55pm UTC](https://discuss.elastic.co/t/initializing-shards-second-db-start-up-takes-long-time/28357 "2015-08-31T13:55:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcin\_es](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@marcin\_es](https://discuss.elastic.co/u/marcin_es)\
**Post date:** [August 31, 2015, 1:55pm UTC](https://discuss.elastic.co/t/initializing-shards-second-db-start-up-takes-long-time/28357/1 "2015-08-31T13:55:27Z")

</div>

Hello all,  
I am working on a solution that uses embedded elasticsearch server - on one local machine. The scenario is:  
1)create cluster with one node. Import data - 3 million records in ~180 indexes and 911 shards. Data is available, search works and returns expected data:  
{  
"cluster\_name" : "cn1441023806894",  
"status" : "green",  
"timed\_out" : false,  
"number\_of\_nodes" : 1,  
"number\_of\_data\_nodes" : 1,  
"active\_primary\_shards" : 911,  
"active\_shards" : 911,  
"relocating\_shards" : 0,  
"initializing\_shards" : 0,  
"unassigned\_shards" : 0  
}

Now, I shutdown the server - this is my console output:  
sie 31, 2015 2:51:36 PM org.elasticsearch.node.internal.InternalNode stop  
INFO: [testbg] stopping ...  
sie 31, 2015 2:51:50 PM org.elasticsearch.node.internal.InternalNode stop  
INFO: [testbg] stopped  
sie 31, 2015 2:51:50 PM org.elasticsearch.node.internal.InternalNode close  
INFO: [testbg] closing ...  
sie 31, 2015 2:51:50 PM org.elasticsearch.node.internal.InternalNode close  
INFO: [testbg] closed

The database folder is around 2.4 GB.

Now i start the server again.... and it takes around 10 minutes to reach status green, example health:  
{  
"cluster\_name" : "cn1441023806894",  
"status" : "red",  
"timed\_out" : false,  
"number\_of\_nodes" : 1,  
"number\_of\_data\_nodes" : 1,  
"active\_primary\_shards" : 68,  
"active\_shards" : 68,  
"relocating\_shards" : 0,  
"initializing\_shards" : 25,  
"unassigned\_shards" : 818  
}

After that process, the database folder is ~0.8 GB.

Then I shutdown the database, and open it again, and now it gets green in 10 seconds.

My configuration:  
settings.put(SET\_NODE\_NAME, projectNameLC);  
settings.put(SET\_PATH\_DATA, projectLocation + "\" + CommonConstants.ANALYZER\_DB\_FOLDER);  
settings.put(SET\_CLUSTER\_NAME, clusterName);  
settings.put(SET\_NODE\_DATA, true);  
settings.put(SET\_NODE\_LOCAL, true);  
settings.put(SET\_INDEX\_REFRESH\_INTERVAL, "-1");  
settings.put(SET\_INDEX\_MERGE\_ASYNC, true);  
//the following settings are my attempt to speed up loading on the 2nd startup  
settings.put("cluster.routing.allocation.disk.threshold\_enabled", false);  
settings.put("index.number\_of\_replicas", 0);  
settings.put("cluster.routing.allocation.disk.include\_relocations", false);  
settings.put("cluster.routing.allocation.node\_initial\_primaries\_recoveries", 25);  
settings.put("cluster.routing.allocation.node\_concurrent\_recoveries", 8);  
settings.put("indices.recovery.concurrent\_streams", 6);  
settings.put("indices.recovery.concurrent\_streams", 6);  
settings.put("indices.recovery.concurrent\_small\_file\_streams", 4);

**The questions:**

1. What happens during the second start up? The db folder size reduces from 2.4gb into 800 megabytes.  
2)If this process is necessary, can it be trigerred manually, so I can show nice "please wait" dialog?

The user experience on teh second database opening is very bad and I need to change it.

Cheers  
Marcin

---

<div class="post-metadata">

**Author:** ![msimos](https://avatars.discourse-cdn.com/v4/letter/m/bb73d2/32.png) [@msimos](https://discuss.elastic.co/u/msimos)\
**Post date:** [August 31, 2015, 6:25pm UTC](https://discuss.elastic.co/t/initializing-shards-second-db-start-up-takes-long-time/28357/2 "2015-08-31T18:25:05Z")

</div>

What version of Elasticsearch are you using? Before shutting down you may want to try issuing a synced flush:

[https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-synced-flush.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-synced-flush.html)

Its only available on Elasticsearch 1.6.0 or later. This may speed up the start up after shutdown.

---

<div class="post-metadata">

**Author:** ![marcin\_es](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@marcin\_es](https://discuss.elastic.co/u/marcin_es)\
**Post date:** [September 1, 2015, 7:58am UTC](https://discuss.elastic.co/t/initializing-shards-second-db-start-up-takes-long-time/28357/3 "2015-09-01T07:58:10Z")

</div>

Hi Mike,  
I was on 1.4, upgraded to 1.7 and now after I finished import to particular index I call the synced flush... and it did the trick!  
I call:

```
client.admin().indices().flush(new FlushRequest(idxName));

```

Thanks for your help!

---

<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:** [July 5, 2017, 11:52pm UTC](https://discuss.elastic.co/t/initializing-shards-second-db-start-up-takes-long-time/28357/4 "2017-07-05T23:52:57Z")

</div>


