# How to Reindex One Billion Documents in One Hour at SoundCloud

DevFeed: [How to Reindex One Billion Documents in One Hour at SoundCloud](<https://devfeed.tech/articles/how-to-reindex-one-billion-documents-in-one-hour-at-soundcloud-2050.md>)

Original publisher: [Read original article](<https://developers.soundcloud.com/blog//how-to-reindex-1-billion-documents-in-1-hour-at-soundcloud>)

Published: 2019-03-21T00:00:00Z

Content type: tutorial

Language: en

Sources: [SoundCloud Backstage](<https://devfeed.tech/sources/soundcloud-backstage-blog.md>)

Topics: [search-engines](<https://devfeed.tech/topics/search-engines.md>), [Concurrency](<https://devfeed.tech/topics/concurrency.md>), [Apache Kafka](<https://devfeed.tech/topics/apache-kafka.md>), [Publish-subscribe pattern](<https://devfeed.tech/topics/pubsub.md>), [lead time](<https://devfeed.tech/topics/lead-time.md>)

Tags: [64gb-ram](<https://devfeed.tech/tags/64gb-ram.md>), [api](<https://devfeed.tech/tags/api.md>), [architecture](<https://devfeed.tech/tags/architecture.md>), [async](<https://devfeed.tech/tags/async.md>), [availability](<https://devfeed.tech/tags/availability.md>), [backend](<https://devfeed.tech/tags/backend.md>), [background](<https://devfeed.tech/tags/background.md>), [batch](<https://devfeed.tech/tags/batch.md>), [berlin](<https://devfeed.tech/tags/berlin.md>), [bug](<https://devfeed.tech/tags/bug.md>), [bug-fix](<https://devfeed.tech/tags/bug-fix.md>), [catalog](<https://devfeed.tech/tags/catalog.md>), [client](<https://devfeed.tech/tags/client.md>), [cluster](<https://devfeed.tech/tags/cluster.md>), [clusters](<https://devfeed.tech/tags/clusters.md>), [commit](<https://devfeed.tech/tags/commit.md>), [elasticsearch](<https://devfeed.tech/tags/elasticsearch.md>), [engineering](<https://devfeed.tech/tags/engineering.md>), [new-feature](<https://devfeed.tech/tags/new-feature.md>), [performance](<https://devfeed.tech/tags/performance.md>), [search](<https://devfeed.tech/tags/search.md>), [users](<https://devfeed.tech/tags/users.md>)

## AI overview

SoundCloud cut Elasticsearch catalog reindexing from as long as a week to one hour by replaying compacted Kafka messages into new clusters and tuning bulk indexing, shard layout, durability, refresh, segment merging, and replication. With 30 nodes, increasing primary shards from 10 to 30 improved indexing throughput; primary-shard indexing for over 720 million documents then took about 30 minutes, down from three hours. The team used concurrent, large bulk requests, disabled replication during reindexing and refreshes, set translog durability to async and its flush threshold to 2 GB, then merged segments and increased recovery concurrency and bandwidth before restoring settings. The 30-shard configuration also reduced latency for 95% of searches to roughly 90 ms. These results were on Elasticsearch 5.6.10; the authors caution that settings and outcomes may differ by version, and further shard and merge strategies remained under investigation.

## Source excerpt

In the past, the Search Team at SoundCloud had high lead times for making updates to Elasticsearch clusters, either during the implementation of a new feature or simply while fixing a bug. This was because both tasks require us to reindex our catalog from scratch, which means reindexing more than 720 million users, tracks, playlists, and albums. Altogether, this process took up to one week, though there was even one scenario where it almost took one month to roll out a bug fix. In this post, I would like to share the concrete Elasticsearch tweaks we made so that we can now reindex our entire catalog in one hour.