Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Part 4: Alias or Index Pattern? Index Design for Two-Way Elasticsearch Replication

In a two-stream design, the index name is the replication contract. Here is how we chose between aliases and index patterns, whether the site suffix can be automated, and how to make an app that breaks the contract fail loudly. Part 2 showed the two-stream design: each site writes indices carrying its own suffix, and the other site follows them. That makes the index name the replication contract.…

In a two-stream design, the index name becomes the replication contract. The choice between using aliases or index patterns, as well as automating the site suffix, affects the replication process. Part 2 of this series introduced the two-stream design, where each site writes indices with its own suffix, and the other site follows them. This post focuses on the design choices that maintain the integrity of the contract.

The index name family _ site _ yyyymm, such as orders_east_202311, determines which cluster leads the index and whether the other site's auto-follow pattern picks it up. The site suffix dictates the replication path. Elasticsearch stores dates in UTC, so applications that compute the month in local time may inadvertently write to the previous month's index.

There are two ways to handle writes: using an alias or providing an explicit name. An alias (e.g., orders_east_write) simplifies the process by eliminating the need for the app to compute index names, as rollover moves the write index automatically. However, an alias can only point to one write index, and rollover runs locally on each cluster.

This setup requires each site to have its own write alias pointing to its own suffix. A potential issue arises when aliases on the follower don't replicate write indices, which may require verification on the specific Elastic version in use.

For readability and straightforward retention, giving monthly names directly has its advantages. The downside is that the app must compute the name, and it requires the create_index privilege. Reads can be handled through an index pattern or a read alias. Index patterns (e.g., orders_*) search every local and replicated index that matches, without the need for updates when new months or followers appear.

However, this approach can catch unintended indices, doesn't allow writes, and spreads the load across many shards. A read alias works universally across sites if the index template adds it to every leader index, enabling global aliases and cleaner permission scoping.

The app or ILM determines the index creation process. When the app creates monthly indices, it handles the naming and rollover based on age or size. The index names are readable, with counter or timestamp suffixes. The site suffix is hard-coded into each cluster's bootstrap index and alias. When the app privileges are aligned with the suffix requirements, retention can be managed externally through jobs or ILM delete phases.

Choosing between app-created indices and ILM rollover involves weighing index names, readability, site suffix, app privileges, and retention methods. A wrongly suffixed index may not trigger an error but will silently fail to replicate, leading to divergent data. Mitigating this risk involves implementing guardrails such as separate application users per site, roles per site with specific privileges, and alerting on potential configuration issues.

An alternative approach involves using ingest pipelines to automate suffixes per cluster, though this incurs overhead and requires identical ingest configurations at both sites. Another option is to bake the site into each cluster's bootstrap index and rollover alias, simplifying the app configuration with guardrails that prevent silent failures.

Regardless of the chosen method, maintaining consistent index settings, such as mappings and retention policies, is crucial. Tools like Cross-Cluster Replication (CCR) replicate index templates but not followers, necessitating additional steps to ensure proper mapping and template distribution. Additionally, monitoring the landing index in cases where ingest pipelines are used can help detect potential issues early.

In summary, the replication contract is primarily governed by the index name, which can be managed through aliases or explicit names. Each method has its advantages and challenges, particularly concerning the site suffix and replication reliability. By carefully considering these factors and implementing appropriate guardrails, organizations can ensure seamless data replication across clusters in an Elasticsearch environment.

Rewritten by urgent.news; may contain errors — check the original. How we use AI.

Source: dev.to

Read the original at dev.to →

More from Dev.to on urgent.news

Get the news by email. Yesterday's most-covered stories, every morning.

We track opens and clicks to improve the newsletter.

See today's edition · More options

More in Tech

How Group Jam keeps everyone in sync without streaming a single byte of audio

Group Jam lets a few friends listen to the same song at the same moment, each on their own phone or desktop. A common first question is "so you stream the audio through your servers?" No. The room…

  • Group Jam synchronizes playback without streaming audio
  • Shared clock and playback anchor keep devices in sync
  • Sync loop corrects drift between room and local player

Schema Markup That Still Matters in 2026

The schema markup that still matters in 2026 is the markup that describes your entity and your page accurately: Organization or LocalBusiness on the business itself, WebSite and WebPage for structure…

  • Schema markup remains relevant in 2026 for accurate entity and page description.
  • Google emphasizes structured data doesn't guarantee rich results or better rankings.

Your PLC Doesn't Care About Your Event Loop

Four lessons from putting asyncio on the factory floor At some point, almost every automation team picks up Python. It rarely starts as a big decision.

  • Round-trips to PLCs are costly; batch requests to reduce latency.
  • Async ADS clients can block event loops if decoding large responses improperly.
  • Separate protocol (ADS) from transport (TCP/MQTT) for easier network changes.

More from Sunday, 6 December 2026 →