# 20 seconds downtime when swapping alias

**URL:** <https://discuss.elastic.co/t/20-seconds-downtime-when-swapping-alias/287739>\
**Category:** Elasticsearch\
**Created:** [October 26, 2021, 9:57pm UTC](https://discuss.elastic.co/t/20-seconds-downtime-when-swapping-alias/287739 "2021-10-26T21:57:51Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![morland96](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/morland96/32/96382_2.png) [@morland96](https://discuss.elastic.co/u/morland96)\
**Post date:** [October 26, 2021, 9:57pm UTC](https://discuss.elastic.co/t/20-seconds-downtime-when-swapping-alias/287739/1 "2021-10-26T21:57:51Z")

</div>

Hi all. I have a service requires zero down time. Since the data need to be versionized, our pipeline will ingest data every day into a new index. After the new index is "green" and able to search, we simply swap the alias with old one. But after the swapping, there is a 20 seconds period that Elasticsearch hang up for the queries. It leads to a 10-25 seconds latency. Any idea how we can avoid that?

For the swapping operation, we tried add the index to that alias and delete old one. But we also tried use the creation and deletion in the same query for atomic operation. Both doesn't work.

---

<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 26, 2021, 10:06pm UTC](https://discuss.elastic.co/t/20-seconds-downtime-when-swapping-alias/287739/2 "2021-10-26T22:06:25Z")

</div>

Welcome to our community! 😃

What version are you on?

> [@morland96](#):
>
> But after the swapping, there is a 20 seconds period that Elasticsearch hang up for the queries. It leads to a 10-25 seconds latency.

Where are you seeing this?

> [@morland96](#):
>
> For the swapping operation, we tried add the index to that alias and delete old one. But we also tried use the creation and deletion in the same query for atomic operation. Both doesn't work.

Doesn't work in what way?

---

<div class="post-metadata">

**Author:** ![morland96](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/morland96/32/96382_2.png) [@morland96](https://discuss.elastic.co/u/morland96)\
**Post date:** [October 26, 2021, 10:23pm UTC](https://discuss.elastic.co/t/20-seconds-downtime-when-swapping-alias/287739/3 "2021-10-26T22:23:50Z")

</div>

The version is 7.13.2.  
The services calling the Elasticsearch were waiting for 20s. But also there is a huge gap in our kibana:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/3/73f5d9112fce9f4c5c09282e10c0d1e24c8898c8.png)  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/1/d/1d168c6047ad93bd30d5af0bc95d70527092e53d.png)

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [October 27, 2021, 12:34am UTC](https://discuss.elastic.co/t/20-seconds-downtime-when-swapping-alias/287739/4 "2021-10-27T00:34:24Z")

</div>

Sounds like the cluster state update might be taking long. What is the full output of the [cluster stats API](https://www.elastic.co/guide/en/elasticsearch/reference/7.15/cluster-stats.html)? What is the specification of your hardware and storage? What type of load is your cluster under?

---

<div class="post-metadata">

**Author:** ![morland96](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/morland96/32/96382_2.png) [@morland96](https://discuss.elastic.co/u/morland96)\
**Post date:** [October 27, 2021, 1:02am UTC](https://discuss.elastic.co/t/20-seconds-downtime-when-swapping-alias/287739/5 "2021-10-27T01:02:37Z")

</div>

The index to swap contains 10,000,000 to 20,000,000 docs. The cluster itself it’s been hold in the azure’s k8s with sufficient high tier resources (cpu/memory/disk loads are in reasonable range). I assume there are some warm up issue after switching alias, just want to know how I can measure it correctly? Currently I’m polling the index till it’s green and switch alias after that. I even test via a small query to make sure it’s actually working. But queries to target alias still freeze when the worker ask for swapping.

---

<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 27, 2021, 1:31am UTC](https://discuss.elastic.co/t/20-seconds-downtime-when-swapping-alias/287739/6 "2021-10-27T01:31:44Z")

</div>

What is the output from the `_cluster/stats?pretty&human` API?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [October 27, 2021, 6:02am UTC](https://discuss.elastic.co/t/20-seconds-downtime-when-swapping-alias/287739/7 "2021-10-27T06:02:25Z")

</div>

It could be caused by a large cluster state, e.g. due to a very high number of shards in the cluster, slow disk I/O or just high load on the cluster.

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [October 27, 2021, 9:14am UTC](https://discuss.elastic.co/t/20-seconds-downtime-when-swapping-alias/287739/8 "2021-10-27T09:14:11Z")

</div>

I would suggest calling `GET _nodes/hot_threads?threads=9999` a few times during the 20-second pause to find out what Elasticsearch is actually doing at that time. One possible explanation is that the caches on this new index are cold, so the first few queries after the switchover have to do a lot of extra work. If so, you can warm it up by doing some realistic queries before the switchover.

---

<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 24, 2021, 9:15am UTC](https://discuss.elastic.co/t/20-seconds-downtime-when-swapping-alias/287739/9 "2021-11-24T09:15:13Z")

</div>

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