# Delay write to replicas while indexing (not initial data population)

**URL:** https://discuss.elastic.co/t/delay-write-to-replicas-while-indexing-not-initial-data-population/316546
**Category:** Elasticsearch
**Created:** [October 13, 2022, 2:23pm UTC](https://discuss.elastic.co/t/delay-write-to-replicas-while-indexing-not-initial-data-population/316546 "2022-10-13T14:23:25Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![stretchy](https://avatars.discourse-cdn.com/v4/letter/s/85e7bf/32.png) [@stretchy](https://discuss.elastic.co/u/stretchy)
#### Post date: [October 13, 2022, 2:23pm UTC](https://discuss.elastic.co/t/delay-write-to-replicas-while-indexing-not-initial-data-population/316546/1 "2022-10-13T14:23:25Z")

</div>

Hi,  
Is there a way to delay writing to replicas while indexing?  
When indexing data continuously, can we reply to the client after writing only to the primary shard, and replica can be written after a while?

Things to note:

- Replicas cannot be reduced to zero. Since data is continuously coming (not initial data population)
- I've looked into index.translog.durability: async and increasing the index.translog.sync\_interval

Another question is does increasing index.translog.sync\_interval means it will put data in the primary shard (node) cache and flush to disk for both primary and replica after this interval, or will data be stored in the cache of primary and replica nodes?

Thanks

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [October 13, 2022, 10:45pm UTC](https://discuss.elastic.co/t/delay-write-to-replicas-while-indexing-not-initial-data-population/316546/2 "2022-10-13T22:45:52Z")

</div>

Why do you want to do this?

---

<div class="post-metadata">

### Author: ![stretchy](https://avatars.discourse-cdn.com/v4/letter/s/85e7bf/32.png) [@stretchy](https://discuss.elastic.co/u/stretchy)
#### Post date: [October 14, 2022, 12:26am UTC](https://discuss.elastic.co/t/delay-write-to-replicas-while-indexing-not-initial-data-population/316546/3 "2022-10-14T00:26:33Z")

</div>

To increase the indexing performance of one index.

---

<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: [October 14, 2022, 12:47am UTC](https://discuss.elastic.co/t/delay-write-to-replicas-while-indexing-not-initial-data-population/316546/4 "2022-10-14T00:47:05Z")

</div>

> [@stretchy](#):
>
> can we reply to the client after writing only to the primary shard, and replica can be written after a while?

That is exactly the default behavior of elasticsearch on index operations.  
See [Here](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html#index-wait-for-active-shards)

> By default, write operations only wait for the primary shards to be active before proceeding (i.e. `wait_for_active_shards=1` ). This default can be overridden in the index settings dynamically by setting `index.write.wait_for_active_shards` . To alter this behavior per operation, the `wait_for_active_shards` request parameter can be used.

Now that IS different that setting replicas to 0 while indexing...

The difference is that resources will still be used to replicate the data to the replica shards

That is why sometimes it makes sense to set replicas to 0 when indexing... perhaps that is what you are thinking of...

But then you say this...

> [@stretchy](#):
>
> Replicas cannot be reduced to zero. Since data is continuously coming (not initial data population)

Which I do not understand ... data coming in continuously is not a requirement to having replicas...

All that said I would look at [How to Tune for Indexing Speed](https://www.elastic.co/guide/en/elasticsearch/reference/current/tune-for-indexing-speed.html) and start with that

---

<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 11, 2022, 12:47am UTC](https://discuss.elastic.co/t/delay-write-to-replicas-while-indexing-not-initial-data-population/316546/5 "2022-11-11T00:47:47Z")

</div>

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