<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Pranay Ravi</title>
    <description>The latest articles on DEV Community by Pranay Ravi (@pranay_raavi).</description>
    <link>https://dev.to/pranay_raavi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3372066%2Fdab53ee7-0e9d-4dab-8313-32931f0fa124.jpg</url>
      <title>DEV Community: Pranay Ravi</title>
      <link>https://dev.to/pranay_raavi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pranay_raavi"/>
    <language>en</language>
    <item>
      <title>Part 8: When CCR Can't Follow: A Version-Agnostic Sync for a 7.x to 8.x Elasticsearch Upgrade and Migration</title>
      <dc:creator>Pranay Ravi</dc:creator>
      <pubDate>Sun, 06 Dec 2026 21:55:02 +0000</pubDate>
      <link>https://dev.to/pranay_raavi/part-8-when-ccr-cant-follow-a-version-agnostic-sync-for-a-7x-to-8x-elasticsearch-upgrade-and-1agc</link>
      <guid>https://dev.to/pranay_raavi/part-8-when-ccr-cant-follow-a-version-agnostic-sync-for-a-7x-to-8x-elasticsearch-upgrade-and-1agc</guid>
      <description>&lt;p&gt;&lt;em&gt;Cross-cluster replication only replicates forward in version, and an 8.x cluster only follows 7.17 or later. For a major upgrade and a platform move in one run, with a way back, I wrote a sync that works at the REST layer.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This is the last part of the series, and the one I'm proudest of, because it is the problem CCR couldn't solve for us.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;We needed to upgrade from 7.x to 8.x and move to a new environment in the same project. CCR's rules ruled it out:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Followers must be the same version or newer&lt;/strong&gt;, down to the patch level. An 8.x follower can only follow a 7.17 or later leader.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Nothing replicates from 8.x back to 7.x.&lt;/strong&gt; After cutover there is no replication stream back to the old cluster, so no rollback path.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Two-way CCR pauses during upgrades.&lt;/strong&gt; Because each cluster follows the other, a bi-directional pair has to pause replication, upgrade both sides and resume. One-way CCR upgrades the follower first, then the leader. Either way, there is no two-way coverage during the window.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CCR needs a transport-layer path&lt;/strong&gt; between the old datacenter and the new environment, plus a subscription on both sides.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The decision: replicate at the REST layer
&lt;/h2&gt;

&lt;p&gt;Every Elasticsearch version speaks JSON over HTTP. A sync that only searches the source and bulk-indexes into the target doesn't care about versions, platforms, the transport layer, or direction. So I built one. The code stays private; the design below is the useful part.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the tool does
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;One-time backfill.&lt;/strong&gt; Scroll each index that matches a pattern and bulk-index into the target with the same &lt;code&gt;_id&lt;/code&gt;. Because ids are preserved, a rerun overwrites instead of duplicating, so every run is idempotent. When the target rejects a request as too large (HTTP 413), the tool halves the batch and retries. Failed documents are logged per index.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Incremental catch-up.&lt;/strong&gt; The watermark for each index is the maximum value of the application's last-updated field already present in the target. It is read from the target at the start of every run, so the tool keeps no external state and recovers on its own after a crash.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Time windows.&lt;/strong&gt; From the watermark, copy fixed windows forward: a day at a time early on, shorter windows near cutover. Skip ahead when the source has nothing newer, and stop at the present.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;An audit trail in both clusters.&lt;/strong&gt; For every window, write one record to a copy-log index on both the source and the target: index, window, document count, status, any error, and both cluster names. Progress is queryable from either side and survives the cutover.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scope to active periods.&lt;/strong&gt; Process only indices whose names fall in the active months, so a run doesn't rescan years of history.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Safe under cron.&lt;/strong&gt; A wrapper takes a lock file with a PID check, clears stale locks, and writes a dated log per day.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A verifier.&lt;/strong&gt; A separate pass pulls (id, last-updated) pairs from both clusters and lists documents that are missing or stale on the target.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgb3tc7rlccs3qv4shdo8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgb3tc7rlccs3qv4shdo8.png" alt="A sync job reads a watermark from the target, copies time windows from the source, and logs progress in both clusters." width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Upgrade and migration in the same run
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Build the new 8.x cluster on the new platform. Pre-create templates, mappings, ILM policies and roles under the new version's rules. 8.x has no mapping types, and because the tool sends only &lt;code&gt;_source&lt;/code&gt;, old type metadata falls away naturally. Data-tier roles replace attribute-based allocation.&lt;/li&gt;
&lt;li&gt;Backfill.&lt;/li&gt;
&lt;li&gt;Run the incremental loop until the lag is a few minutes.&lt;/li&gt;
&lt;li&gt;Freeze writers, run a final pass, and get a clean verifier report.&lt;/li&gt;
&lt;li&gt;Cut the applications over.&lt;/li&gt;
&lt;li&gt;Flip the direction: sync new to old during a safety window. That is the rollback path CCR can't give you.&lt;/li&gt;
&lt;li&gt;Decommission the old cluster.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Set ILM origination dates on backfilled history, or old months will look new to ILM (Part 5).&lt;/p&gt;

&lt;h2&gt;
  
  
  Limits, honestly
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Hard deletes are invisible&lt;/strong&gt; to a watermark. Use a soft-delete flag or tombstones, or rely on the verifier to catch them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It depends on a trustworthy last-updated field&lt;/strong&gt; that the application sets on every write. Clock skew and late writes call for overlapping windows; because ids are preserved, re-copying the overlap is safe.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It is slower than CCR's file-level copy.&lt;/strong&gt; It is built for catch-up, not continuous low-latency replication.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;On newer versions, prefer point-in-time with &lt;code&gt;search_after&lt;/code&gt;&lt;/strong&gt; over scroll for large reads.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep TLS verification on and credentials in a secrets store&lt;/strong&gt;, not in a config file beside the script. That one is a lesson from the early versions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Choosing an approach
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Approach&lt;/th&gt;
&lt;th&gt;Recovery point&lt;/th&gt;
&lt;th&gt;DR readable?&lt;/th&gt;
&lt;th&gt;Crosses versions?&lt;/th&gt;
&lt;th&gt;Ops cost&lt;/th&gt;
&lt;th&gt;Best for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Snapshot and restore (SLM)&lt;/td&gt;
&lt;td&gt;Hours&lt;/td&gt;
&lt;td&gt;Not during restores&lt;/td&gt;
&lt;td&gt;Forward one major&lt;/td&gt;
&lt;td&gt;Low to medium&lt;/td&gt;
&lt;td&gt;Backups, cold DR&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CCR, one-way&lt;/td&gt;
&lt;td&gt;Near real time&lt;/td&gt;
&lt;td&gt;Yes, read-only&lt;/td&gt;
&lt;td&gt;Follower same or newer&lt;/td&gt;
&lt;td&gt;Medium&lt;/td&gt;
&lt;td&gt;Warm DR, read offload&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CCR, two streams&lt;/td&gt;
&lt;td&gt;Near real time&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;In practice, same version&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;td&gt;Two active sites, append-mostly data&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;REST-level sync&lt;/td&gt;
&lt;td&gt;Minutes (window size)&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Any direction&lt;/td&gt;
&lt;td&gt;Medium; you own the code&lt;/td&gt;
&lt;td&gt;Upgrades, migrations, rollback&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dual write or Kafka fan-out&lt;/td&gt;
&lt;td&gt;Depends on the pipeline&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;High (consistency)&lt;/td&gt;
&lt;td&gt;Source of truth upstream, replayable&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cross-cluster search&lt;/td&gt;
&lt;td&gt;No copy&lt;/td&gt;
&lt;td&gt;Queries go remote&lt;/td&gt;
&lt;td&gt;Within compatibility rules&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;Global reads without copying&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;OpenSearch cross-cluster replication&lt;/td&gt;
&lt;td&gt;Near real time&lt;/td&gt;
&lt;td&gt;Yes, read-only&lt;/td&gt;
&lt;td&gt;Within its own rules&lt;/td&gt;
&lt;td&gt;Medium&lt;/td&gt;
&lt;td&gt;Teams already on OpenSearch&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Series wrap-up
&lt;/h2&gt;

&lt;p&gt;Nothing in this series is exotic. Every piece is a documented feature. The work was in the seams: index names that encode ownership, metadata that doesn't travel, versions that only move forward, and monitoring that tells you when replication has quietly stopped. If you take three habits away, take these: write a heartbeat and alert on it, keep everything that isn't data in code applied to both clusters, and plan your way back before you need it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Risks and precautions
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A watermark sync misses hard deletes unless you design for them.&lt;/li&gt;
&lt;li&gt;Your rollback window is only as good as the reverse sync running during it. Test the flip before cutover day.&lt;/li&gt;
&lt;li&gt;Pre-create templates and mappings on the target. Letting the target guess mappings from the first documents is how fields end up with the wrong type.&lt;/li&gt;
&lt;li&gt;Keep the verifier report as your cutover sign-off.&lt;/li&gt;
&lt;li&gt;Own the code: a home-grown sync needs tests, logs and an owner, just like any production service.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fggpd0cr2dc7usodkh4mc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fggpd0cr2dc7usodkh4mc.png" alt="Eight numbered tiles marking the completed series, with the words Plan the way back before you need it." width="799" height="294"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Part 8 of 8 in &lt;a href="https://dev.to/pranay_raavi/series/47931"&gt;Elasticsearch Replication &amp;amp; DR Field Notes&lt;/a&gt;. Previous: Part 7, Failover, Failback, and the 2,000-Index Unfollow Problem. Start of series: Part 1, Elasticsearch DR the Hard Way.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.elastic.co/docs/deploy-manage/tools/cross-cluster-replication" rel="noopener noreferrer"&gt;Elastic docs: Cross-cluster replication (version compatibility, upgrading clusters)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.elastic.co/docs/deploy-manage/tools/cross-cluster-replication/bi-directional-disaster-recovery" rel="noopener noreferrer"&gt;Elastic docs: Bi-directional disaster recovery&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>elasticsearch</category>
      <category>python</category>
      <category>database</category>
      <category>devops</category>
    </item>
    <item>
      <title>Part 7: Failover, Failback, and the 2,000-Index Unfollow Problem</title>
      <dc:creator>Pranay Ravi</dc:creator>
      <pubDate>Sun, 06 Dec 2026 21:47:22 +0000</pubDate>
      <link>https://dev.to/pranay_raavi/part-7-failover-failback-and-the-2000-index-unfollow-problem-3efi</link>
      <guid>https://dev.to/pranay_raavi/part-7-failover-failback-and-the-2000-index-unfollow-problem-3efi</guid>
      <description>&lt;p&gt;&lt;em&gt;Cross-cluster replication makes the steady state easy. Reversing it, recovering from failures, and noticing when it has quietly stopped are the hard parts.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The proof of concept made the happy path look easy. This post is about the other paths.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two kinds of failover
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;In the two-stream design (Part 2), there is no write failover.&lt;/strong&gt; If a site goes down, the other site keeps writing its own indices. What you lose is whatever the surviving site hadn't pulled yet, so your recovery point equals the replication lag at the moment of failure. When the failed site returns within the soft-delete retention lease, its followers catch up on their own. If it returns after the lease expires, you recreate those followers, which means a full copy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In a single-writer design (one-way DR), you promote followers&lt;/strong&gt; so the DR site can take writes. That is where the work is.&lt;/p&gt;

&lt;h2&gt;
  
  
  Promoting followers: one index at a time
&lt;/h2&gt;

&lt;p&gt;Each follower becomes a regular index in four steps: pause, close, unfollow, open. There is no wildcard. In our proof of concept, a pattern-based unfollow simply wasn't possible.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="no"&gt;POST&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;orders_east_202311&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;_ccr&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;pause_follow&lt;/span&gt;
&lt;span class="no"&gt;POST&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;orders_east_202311&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;_close&lt;/span&gt;
&lt;span class="no"&gt;POST&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;orders_east_202311&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;_ccr&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;unfollow&lt;/span&gt;
&lt;span class="no"&gt;POST&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;orders_east_202311&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;_open&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With about 2,000 indices, that is a script. Ours needed to build the index list dynamically from &lt;code&gt;GET /*/_ccr/info&lt;/code&gt;, be safe to rerun if it stopped halfway, and log every step per index.&lt;/p&gt;

&lt;h2&gt;
  
  
  Failback is the expensive part
&lt;/h2&gt;

&lt;p&gt;When the old primary comes back, it still holds indices with the same names. A follower can't be created where a same-named index exists, so those indices have to be deleted and then followed again from the new primary. That is a remote recovery, which means a full copy. For about 2,000 indices we estimated up to 10 hours. Then you recreate the auto-follow patterns in the new direction.&lt;/p&gt;

&lt;p&gt;The consequence: there is no quick rollback. Once you promote DR and it takes writes, the only way back is another full copy. Elastic's one-way DR tutorial follows the same failover and failback model.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fu54j5u5lfvhy262xs75d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fu54j5u5lfvhy262xs75d.png" alt="Timeline of normal replication, failover by promoting followers, and failback by a full re-copy." width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Failures, restarts, and how much you can lose
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Transient errors&lt;/strong&gt;, such as a network blip: follower shards retry on their own.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fatal errors&lt;/strong&gt;: the follower pauses until someone resumes it. It stalls silently unless you are watching.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;An outage longer than the retention lease&lt;/strong&gt;: the leader may discard operations the follower never pulled, and the follower can't catch up. Recreate it, which is a full copy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A follower index deleted on the target&lt;/strong&gt;: auto-follow doesn't recreate it, and in our 7.x tests no error surfaced anywhere obvious. That index simply stopped replicating.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A static setting change on the leader&lt;/strong&gt;: the follower closes, applies it and reopens, so DR reads on that index blip.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Site loss&lt;/strong&gt;: operations not yet pulled are stranded until the site returns. If it never returns, they are gone.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Monitoring a NOC can actually use
&lt;/h2&gt;

&lt;p&gt;Kibana's CCR page is fine for an engineer looking at one cluster. It isn't something a NOC can alert on. We scripted these checks, each producing one number in the monitoring tool with a threshold:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Heartbeat lag per direction.&lt;/strong&gt; The same pattern from Part 1: a timestamp written at the source and read at the destination.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Follower shard health&lt;/strong&gt; from &lt;code&gt;_ccr/stats&lt;/code&gt;: any &lt;code&gt;fatal_exception&lt;/code&gt;, a growing &lt;code&gt;time_since_last_read_millis&lt;/code&gt;, and the gap between leader and follower global checkpoints.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Auto-follow errors&lt;/strong&gt; from the auto-follow stats (&lt;code&gt;recent_auto_follow_errors&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Inventory diff&lt;/strong&gt;: leader indices that match a pattern compared with follower indices that actually exist. This is what catches deleted followers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Doc-count difference&lt;/strong&gt; per index family, with a tolerance for in-flight writes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Log scraping&lt;/strong&gt; on the master nodes for auto-follow errors.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A liveness metric for every script&lt;/strong&gt;, so a dead check alerts instead of looking green.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you already run Metricbeat, it has a CCR metricset that covers part of this.&lt;/p&gt;

&lt;h2&gt;
  
  
  A planned switch, in order
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Freeze writers: stop data loads and lock the loader accounts at both sites.&lt;/li&gt;
&lt;li&gt;Confirm lag is zero with the heartbeat, and that doc counts match.&lt;/li&gt;
&lt;li&gt;Promote followers, or in the two-stream design just repoint the applications.&lt;/li&gt;
&lt;li&gt;Move saved objects and security state, if they aren't already automated (Part 6).&lt;/li&gt;
&lt;li&gt;Re-establish replication in the new direction and confirm heartbeats flow.&lt;/li&gt;
&lt;li&gt;Unlock writers and watch lag for the first hour.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Rehearse it on a staging pair first. Our staging switch is where most of these steps came from.&lt;/p&gt;

&lt;h2&gt;
  
  
  Risks and precautions
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A paused follower looks healthy on any dashboard that only checks cluster health.&lt;/li&gt;
&lt;li&gt;A retention lease shorter than your outage turns a catch-up into a full re-copy.&lt;/li&gt;
&lt;li&gt;Failback is a full copy. Budget the hours and the bandwidth before you need them.&lt;/li&gt;
&lt;li&gt;There is no wildcard unfollow. Script it, make it rerunnable, and test it.&lt;/li&gt;
&lt;li&gt;Deleted followers stop replicating silently. Run the inventory diff.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1aby1p1uzzv4cm1kknqu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1aby1p1uzzv4cm1kknqu.png" alt="Three replication gauges and a heartbeat line with the words Silence is not health." width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Part 7 of 8 in &lt;a href="https://dev.to/pranay_raavi/series/47931"&gt;Elasticsearch Replication &amp;amp; DR Field Notes&lt;/a&gt; . Previous: Part 6, What CCR Won't Copy. Next: Part 8, When CCR Can't Follow.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.elastic.co/docs/deploy-manage/tools/cross-cluster-replication" rel="noopener noreferrer"&gt;Elastic docs: Cross-cluster replication (replication mechanics, soft deletes, recreating followers)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>elasticsearch</category>
      <category>devops</category>
      <category>database</category>
      <category>monitoring</category>
    </item>
    <item>
      <title>Part 6: What CCR Won't Copy: Security, Saved Objects, and the Metadata Gap</title>
      <dc:creator>Pranay Ravi</dc:creator>
      <pubDate>Sun, 06 Dec 2026 21:40:31 +0000</pubDate>
      <link>https://dev.to/pranay_raavi/part-6-what-ccr-wont-copy-security-saved-objects-and-the-metadata-gap-20m7</link>
      <guid>https://dev.to/pranay_raavi/part-6-what-ccr-wont-copy-security-saved-objects-and-the-metadata-gap-20m7</guid>
      <description>&lt;p&gt;&lt;em&gt;Cross-cluster replication copies documents in user indices. Users, roles, dashboards, templates and policies are yours to move. Here is how we closed the gap, including the security index workaround we ran on 7.x.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The first time you fail over to a CCR follower, you find out what replication didn't bring along. Better to find out on a whiteboard.&lt;/p&gt;

&lt;h2&gt;
  
  
  What replicates and what doesn't
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Item&lt;/th&gt;
&lt;th&gt;Replicated by CCR?&lt;/th&gt;
&lt;th&gt;How we handled it&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Documents in user indices&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Leader and follower indices&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mappings and most index settings&lt;/td&gt;
&lt;td&gt;Yes, from the leader&lt;/td&gt;
&lt;td&gt;Nothing to do&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Alias membership&lt;/td&gt;
&lt;td&gt;Yes, but &lt;code&gt;is_write_index&lt;/code&gt; is forced to false&lt;/td&gt;
&lt;td&gt;Site-local write aliases (Part 4)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Replica count changes on the leader&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Set replicas on each cluster&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Index templates&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Config as code, applied to both&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ILM and SLM policies&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Config as code, same names on both (Part 5)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ingest pipelines and cluster settings&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Config as code, with per-site variables&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Users, roles, role mappings&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Snapshot and restore, or external identity&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;System indices (security, Kibana saved objects)&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Snapshot and restore; saved-object export&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Watchers and machine learning jobs&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Recreate from code on both clusters&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Searchable snapshot indices&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Same repository setup and policy on each cluster&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Snapshot repository settings&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Configure each cluster's repositories&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Security: what didn't work
&lt;/h2&gt;

&lt;p&gt;In the proof of concept, we tried the obvious things first. An auto-follow pattern on the security index could be created, but users added on the primary never appeared on DR. A follower can't be created for a dot-prefixed system index, and a follower can't be created where an index with the same name already exists. Native replication was a dead end.&lt;/p&gt;

&lt;h2&gt;
  
  
  What we ran on 7.x: scheduled snapshot and restore
&lt;/h2&gt;

&lt;p&gt;We confirmed the approach with the vendor's support team before building it.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Every hour, snapshot the security index on the primary into a dedicated repository.&lt;/li&gt;
&lt;li&gt;That repository replicates to DR with the rest of the snapshot storage.&lt;/li&gt;
&lt;li&gt;At DR, restore the latest snapshot under a new, timestamped index name (&lt;code&gt;.security-&amp;lt;timestamp&amp;gt;&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Atomically repoint the &lt;code&gt;.security&lt;/code&gt; alias from the old copy to the new one. The previous copy stays in place, so rollback is a single alias swap.&lt;/li&gt;
&lt;li&gt;Prune copies older than 15 days.&lt;/li&gt;
&lt;li&gt;Alert if the newest snapshot being restored is more than 2 hours old, or if a snapshot or restore fails. Each script also emits a "job ran" metric, so a dead cron job raises an alert too.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fex5yyy5sysn5co9jek1i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fex5yyy5sysn5co9jek1i.png" alt="Hourly security snapshot restored at DR under a timestamped name, with an alias swap and a rollback copy." width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On current versions, don't touch the security index directly. Elastic's docs say security configuration isn't replicated by CCR and recommend regular snapshots of the &lt;code&gt;security&lt;/code&gt; feature state, which you restore to bring back native users, roles and tokens. The idea is the same as ours; the mechanism is supported and simpler.&lt;/p&gt;

&lt;h2&gt;
  
  
  The gotcha: the restore broke replication
&lt;/h2&gt;

&lt;p&gt;Restoring the primary's security state onto DR overwrote DR-local pieces that replication depended on, and CCR broke. The fix was symmetry. Both clusters define both remote clusters, both auto-follow patterns, and the same replication users and roles. After that, an overwrite from either direction changes nothing replication needs. This is why Part 3 recommends defining both sides on both clusters from day one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Better still: don't replicate identity at all
&lt;/h2&gt;

&lt;p&gt;If I built this today, I would externalize authentication through SAML, OIDC or LDAP, and keep role definitions and role mappings in git, applied to both clusters by a pipeline. Then only a few native and service accounts remain to sync.&lt;/p&gt;

&lt;p&gt;What about remote reindex from the primary? It is a good tool for one-off copies of user indices. It is not a way to copy the security index.&lt;/p&gt;

&lt;h2&gt;
  
  
  Saved objects
&lt;/h2&gt;

&lt;p&gt;Dashboards, visualizations and saved searches live in a Kibana system index, so CCR skips them. Export and import them through the Saved Objects API on a schedule, or keep them in git. We moved them by hand during every DR switch, which is exactly the kind of step that gets forgotten at 2 a.m. Automate it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Templates, policies, pipelines and cluster settings
&lt;/h2&gt;

&lt;p&gt;Keep them as code in one repository and apply it to both clusters, with per-site variables such as the site suffix and remote cluster names. Add a nightly drift check that compares templates, ILM and SLM policies, pipelines and roles between the clusters and alerts on any difference.&lt;/p&gt;

&lt;h2&gt;
  
  
  Node configuration: back up per site, never cross-restore
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;elasticsearch.yml&lt;/code&gt;, &lt;code&gt;jvm.options&lt;/code&gt;, &lt;code&gt;log4j2.properties&lt;/code&gt;, the keystore and OS limits are specific to each node and site. Back them up daily per site, in version control or file backup, along with a dump of the persistent cluster settings (&lt;code&gt;GET _cluster/settings?flat_settings&amp;amp;filter_path=persistent&lt;/code&gt;). Never restore the primary's configuration onto DR: node names, paths, seeds and certificates all differ.&lt;/p&gt;

&lt;h2&gt;
  
  
  Risks and precautions
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Assume DR has no users until you prove otherwise, or your first failover locks everyone out.&lt;/li&gt;
&lt;li&gt;Keep the previous security copy, so a bad restore rolls back in one step.&lt;/li&gt;
&lt;li&gt;Alert on stale security snapshots. A silently old restore is worse than a failed one.&lt;/li&gt;
&lt;li&gt;Automate saved-object sync before the outage, not during it.&lt;/li&gt;
&lt;li&gt;Run a drift check. Two clusters configured by hand will diverge.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjf2sy1743vl12d28mup4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjf2sy1743vl12d28mup4.png" alt="Security config in version control applied to both clusters, with the words If it isn't data, it's code." width="799" height="294"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Part 6 of 8 in &lt;a href="https://dev.to/pranay_raavi/series/47931"&gt;Elasticsearch Replication &amp;amp; DR Field Notes&lt;/a&gt; . Previous: Part 5, CCR Meets ILM. Next: Part 7, Failover, Failback, and the 2,000-Index Unfollow Problem.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.elastic.co/docs/deploy-manage/tools/cross-cluster-replication" rel="noopener noreferrer"&gt;Elastic docs: Cross-cluster replication (limitations; security not replicated; feature-state snapshots)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>elasticsearch</category>
      <category>devops</category>
      <category>database</category>
      <category>sre</category>
    </item>
    <item>
      <title>Part 5: CCR Meets ILM: Rollover, Retention, and Two Clusters That Both Think They're in Charge</title>
      <dc:creator>Pranay Ravi</dc:creator>
      <pubDate>Sun, 06 Dec 2026 21:36:12 +0000</pubDate>
      <link>https://dev.to/pranay_raavi/part-5-ccr-meets-ilm-rollover-retention-and-two-clusters-that-both-think-theyre-in-charge-40bh</link>
      <guid>https://dev.to/pranay_raavi/part-5-ccr-meets-ilm-rollover-retention-and-two-clusters-that-both-think-theyre-in-charge-40bh</guid>
      <description>&lt;p&gt;&lt;em&gt;Index lifecycle management runs per cluster, and cross-cluster replication copies indices, not policies. Here are the six seams where they collide in a two-site design.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;We ran an ILM proof of concept a few months after the CCR one. Most of what we learned wasn't about ILM itself. It was about the seams between ILM and replication.&lt;/p&gt;

&lt;h2&gt;
  
  
  ILM in one paragraph
&lt;/h2&gt;

&lt;p&gt;ILM moves time-series indices through phases (hot, warm, cold, frozen, delete) and runs actions in each: rollover, shrink, force merge, allocate, searchable snapshot, delete. How data reaches the right nodes changed over the 7.x line. Early 7.x used custom node attributes (&lt;code&gt;box_type: hot&lt;/code&gt;), while 7.10 and later use data-tier node roles (&lt;code&gt;data_hot&lt;/code&gt;, &lt;code&gt;data_warm&lt;/code&gt;, &lt;code&gt;data_cold&lt;/code&gt;) and &lt;code&gt;_tier_preference&lt;/code&gt;. Newer versions add a frozen tier backed by searchable snapshots, plus downsampling for metrics. If you move from 7.x to 8.x, rewrite any attribute-based allocation in your policies.&lt;/p&gt;

&lt;h2&gt;
  
  
  Seam 1: policy names travel, policies don't
&lt;/h2&gt;

&lt;p&gt;CCR copies the &lt;code&gt;index.lifecycle.name&lt;/code&gt; setting from the leader to the follower, but it doesn't replicate the policy definition. Define a policy with the same name on both clusters, or every replicated index hits ILM errors on the follower side. Treat ILM policies as code applied to both clusters.&lt;/p&gt;

&lt;h2&gt;
  
  
  Seam 2: deleting an index never replicates
&lt;/h2&gt;

&lt;p&gt;CCR replicates document deletes, but deleting a leader index doesn't delete its follower. Retention has to run on both clusters. If East keeps 13 months and West keeps 18, the same query returns different answers depending on which site you ask. Keep retention identical, and make any site-specific exception explicit and documented.&lt;/p&gt;

&lt;h2&gt;
  
  
  Seam 3: followers can't roll over
&lt;/h2&gt;

&lt;p&gt;A follower is read-only, so it can't roll over or shrink itself. Elastic's docs describe how ILM coordinates rollover and unfollow for auto-followed indices: the follower waits for the leader to finish with an index, then unfollows before actions that need a writable index. After that, the follower is a regular index and no longer replicates. That is fine for a closed month, but remember it when you debug why a later change didn't arrive. Verify the exact behavior on your version.&lt;/p&gt;

&lt;h2&gt;
  
  
  Seam 4: calendar months
&lt;/h2&gt;

&lt;p&gt;ILM rollover triggers on age, size or document count, never on the calendar. &lt;code&gt;max_age: 30d&lt;/code&gt; drifts away from month boundaries. Date math index names, such as &lt;code&gt;&amp;lt;orders_east-{now/M{yyyy.MM}}-000001&amp;gt;&lt;/code&gt;, stamp the time the index was created, not the month of the data in it. Two ways out:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An external scheduler that calls &lt;code&gt;_rollover&lt;/code&gt; at midnight UTC on the first of the month.&lt;/li&gt;
&lt;li&gt;Monthly indices named by the app or an ingest pipeline (Part 4), with ILM used only for the delete phase.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Seam 5: ILM ages by creation date, not by name
&lt;/h2&gt;

&lt;p&gt;ILM measures an index's age from its creation or rollover date, not from the date in its name. An index backfilled or migrated today for a month two years ago looks brand new, and it survives well past its retention. When you load historical indices, set &lt;code&gt;index.lifecycle.origination_date&lt;/code&gt;, or have ILM parse the date from the index name. This matters most during migrations (Part 8).&lt;/p&gt;

&lt;h2&gt;
  
  
  Seam 6: template patterns that reach too far
&lt;/h2&gt;

&lt;p&gt;Don't attach an ILM policy through a template whose pattern also matches long-lived single indices or system indices. A delete phase on the wrong pattern deletes the wrong things, on each cluster where the template exists. Scope ILM templates to time-series families only.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F593em6rsu388dxe0apel.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F593em6rsu388dxe0apel.png" alt="CCR copies the index and its lifecycle name, but not the policy definition or index deletions." width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  ILM versus ISM, if you might land on OpenSearch
&lt;/h2&gt;

&lt;p&gt;OpenSearch's Index State Management (ISM) follows the same idea with a different API and policy syntax, and it interacts differently with OpenSearch's own replication. Don't port policies mechanically. Re-test rollover and replication together on the target platform.&lt;/p&gt;

&lt;h2&gt;
  
  
  The ILM APIs we lived in
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GET  /orders_east_202311/_ilm/explain   # where is this index, and why is it stuck?
POST /orders_east_202311/_ilm/retry     # retry after fixing the cause
GET  /_ilm/status
POST /_ilm/stop
POST /_ilm/start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Risks and precautions
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A policy missing on the follower cluster means ILM errors on every replicated index.&lt;/li&gt;
&lt;li&gt;Mismatched retention means each site answers the same question differently.&lt;/li&gt;
&lt;li&gt;A broad template pattern plus a delete phase means data loss.&lt;/li&gt;
&lt;li&gt;Backfilled indices escape retention unless you set their origination date.&lt;/li&gt;
&lt;li&gt;A short &lt;code&gt;indices.lifecycle.poll_interval&lt;/code&gt; belongs in test only.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6f80o21mbo4tzxr3knuc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6f80o21mbo4tzxr3knuc.png" alt="Two matching policy cards with the words Same policy, same retention, both clusters." width="799" height="294"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Part 5 of 8 in  &lt;a href="https://dev.to/pranay_raavi/series/47931"&gt;Elasticsearch Replication &amp;amp; DR Field Notes&lt;/a&gt; . Previous: Part 4, Alias or Index Pattern? Next: Part 6, What CCR Won't Copy.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.elastic.co/docs/deploy-manage/tools/cross-cluster-replication" rel="noopener noreferrer"&gt;Elastic docs: Cross-cluster replication (index deletions, ILM, limitations)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>elasticsearch</category>
      <category>devops</category>
      <category>database</category>
      <category>sre</category>
    </item>
    <item>
      <title>Part 4: Alias or Index Pattern? Index Design for Two-Way Elasticsearch Replication</title>
      <dc:creator>Pranay Ravi</dc:creator>
      <pubDate>Sun, 06 Dec 2026 21:28:07 +0000</pubDate>
      <link>https://dev.to/pranay_raavi/part-4-alias-or-index-pattern-index-design-for-two-way-elasticsearch-replication-54oj</link>
      <guid>https://dev.to/pranay_raavi/part-4-alias-or-index-pattern-index-design-for-two-way-elasticsearch-replication-54oj</guid>
      <description>&lt;p&gt;&lt;em&gt;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.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;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. This post covers the design decisions that keep the contract intact.&lt;/p&gt;

&lt;h2&gt;
  
  
  The contract
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;family&amp;gt;_&amp;lt;site&amp;gt;_&amp;lt;yyyymm&amp;gt;&lt;/code&gt;, for example &lt;code&gt;orders_east_202311&lt;/code&gt;. The site suffix decides which cluster leads the index and whether the other site's auto-follow pattern picks it up. The month decides retention.&lt;/p&gt;

&lt;p&gt;Watch the clock. Elasticsearch stores dates in UTC. An application that computes the month in local time writes the first hours of each month into the previous month's index.&lt;/p&gt;

&lt;h2&gt;
  
  
  Writes: alias or explicit name
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;A write alias&lt;/strong&gt; (say &lt;code&gt;orders_east_write&lt;/code&gt;, with &lt;code&gt;is_write_index&lt;/code&gt; on the current month's index) means the app never computes index names, and rollover moves the write index. The limits: an alias has exactly one write index, rollover runs locally on each cluster, and in a two-stream design each site needs its own write alias pointing at its own suffix.&lt;/p&gt;

&lt;p&gt;What happens to aliases on the follower? Current Elastic docs say alias changes on a leader index replicate to its followers, but &lt;code&gt;is_write_index&lt;/code&gt; is forced to false there, because followers can't take writes. So replication can't hand the other site a second write index. That was an open question in our original design. Confirm it on your version before you depend on it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;An explicit monthly name&lt;/strong&gt; gives readable names and simple retention by name. The cost: the app must compute the name, and it needs the &lt;code&gt;create_index&lt;/code&gt; privilege.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reads: index pattern or read alias
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;An index pattern&lt;/strong&gt; (&lt;code&gt;orders_*&lt;/code&gt;) searches every local and replicated index that matches, with no upkeep when a new month or a new follower appears. The downsides: it also catches anything else that matches, such as a stray test index; you can't write through it; and a broad pattern fans out to many shards.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A read alias&lt;/strong&gt; works across sites if the index template adds it (say &lt;code&gt;orders_read&lt;/code&gt;) to every leader index, because alias membership replicates with the follower. That gives each site a global alias, which is also cleaner to scope permissions on. On 7.x we read through patterns, because they didn't depend on alias replication behavior.&lt;/p&gt;

&lt;p&gt;Our rule: write through a site-local alias or exact name; read through a pattern or read alias that spans both sites.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnnzdhd6zuik55phwgsnz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnnzdhd6zuik55phwgsnz.png" alt="The app writes to one local index through an alias and reads all local and replicated indices through a pattern." width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Who creates the index: the app or ILM
&lt;/h2&gt;

&lt;p&gt;This is the comparison we worked through in the design review.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Criterion&lt;/th&gt;
&lt;th&gt;App creates monthly indices&lt;/th&gt;
&lt;th&gt;ILM rollover creates indices&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Index names&lt;/td&gt;
&lt;td&gt;Readable: &lt;code&gt;orders_east_202311&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Counter or timestamp suffix; rollover is by age or size, not calendar month&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Site suffix&lt;/td&gt;
&lt;td&gt;From app config&lt;/td&gt;
&lt;td&gt;Hard-coded into each cluster's bootstrap index and alias&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Knowing where to write&lt;/td&gt;
&lt;td&gt;App computes the current month&lt;/td&gt;
&lt;td&gt;The write alias handles it&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;App privileges&lt;/td&gt;
&lt;td&gt;Needs &lt;code&gt;create_index&lt;/code&gt; (scope it)&lt;/td&gt;
&lt;td&gt;Needs write on the alias only&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Retention&lt;/td&gt;
&lt;td&gt;External job or ILM delete phase&lt;/td&gt;
&lt;td&gt;ILM&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Typical failure&lt;/td&gt;
&lt;td&gt;Wrong config produces a wrong name&lt;/td&gt;
&lt;td&gt;Missing bootstrap makes writes fail&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Can the site suffix be automated without app config?
&lt;/h2&gt;

&lt;p&gt;Yes. There are three ways, each with its own overhead.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;An ingest pipeline per cluster.&lt;/strong&gt; The app writes to a site-agnostic landing index, &lt;code&gt;orders&lt;/code&gt;. That index's &lt;code&gt;default_pipeline&lt;/code&gt; uses the &lt;code&gt;date_index_name&lt;/code&gt; processor with the prefix &lt;code&gt;orders_east_&lt;/code&gt; on East and &lt;code&gt;orders_west_&lt;/code&gt; on West, routing each document to the right monthly site index by its timestamp. App config is identical at both sites. The overhead: ingest work on every document; two pipelines that must stay identical apart from the prefix; target indices that are auto-created, so templates and &lt;code&gt;action.auto_create_index&lt;/code&gt; must allow the pattern; and if the pipeline is ever missing, documents land in the landing index, which nothing replicates. Alert whenever the landing index holds any documents, and test how privileges apply to rerouted writes on your version.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;An ILM bootstrap per cluster.&lt;/strong&gt; Bake the site into each cluster's bootstrap index and rollover alias. The app writes to the alias and never sees the suffix.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;App config with guardrails.&lt;/strong&gt; The suffix comes from config, and the app refuses to start if it is empty.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We chose the third option for readable monthly names, with the guardrails below, and kept retention with the operations team.&lt;/p&gt;

&lt;h2&gt;
  
  
  Guardrails that make a wrong suffix fail loudly
&lt;/h2&gt;

&lt;p&gt;A wrongly suffixed index doesn't raise an error. It simply never matches the other site's auto-follow pattern, so it never replicates. That is silent divergence, the worst kind. The fix is to make it a permissions error:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A separate application user per site.&lt;/li&gt;
&lt;li&gt;A role per site that grants &lt;code&gt;create_index&lt;/code&gt;, &lt;code&gt;index&lt;/code&gt;, &lt;code&gt;write&lt;/code&gt; and &lt;code&gt;read&lt;/code&gt; only on that site's pattern, plus &lt;code&gt;read&lt;/code&gt; on the whole family. A misconfigured app gets a 403 instead of creating an index nobody follows.&lt;/li&gt;
&lt;li&gt;The app refuses to start if its site suffix is missing.&lt;/li&gt;
&lt;li&gt;Retention belongs to the platform team, not the app.&lt;/li&gt;
&lt;li&gt;The same index template on both clusters: mappings, the timestamp field, and the retention lease. CCR doesn't replicate templates, and followers take their mappings from the leader.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;POST /_security/role/orders_app_east
{
  "indices": [
    { "names": ["orders_east*"], "privileges": ["create_index", "index", "write", "read"] },
    { "names": ["orders_*"], "privileges": ["read"] }
  ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Risks and precautions
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A wrong suffix means silent non-replication. Make it a 403.&lt;/li&gt;
&lt;li&gt;Compute month boundaries in UTC.&lt;/li&gt;
&lt;li&gt;Index patterns fan out. Keep families tight and size your shards.&lt;/li&gt;
&lt;li&gt;If you route with an ingest pipeline, alert on the landing index.&lt;/li&gt;
&lt;li&gt;Verify alias replication on your version before relying on a global read alias.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fde3c51ejb1025gqbjamn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fde3c51ejb1025gqbjamn.png" alt="An index name tag beside a 403 shield, with the words Make the wrong name fail loudly." width="799" height="294"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Part 4 of 8 in &lt;a href="https://dev.to/pranay_raavi/series/47931"&gt;Elasticsearch Replication &amp;amp; DR Field Notes&lt;/a&gt; . Previous: Part 3, the settings that bite. Next: Part 5, CCR Meets ILM.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.elastic.co/docs/deploy-manage/tools/cross-cluster-replication" rel="noopener noreferrer"&gt;Elastic docs: Cross-cluster replication (processing updates, aliases, templates)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>elasticsearch</category>
      <category>architecture</category>
      <category>database</category>
      <category>devops</category>
    </item>
    <item>
      <title>Part 3: Before You Turn On CCR: The Settings That Matter and the Ones That Bite</title>
      <dc:creator>Pranay Ravi</dc:creator>
      <pubDate>Sun, 06 Dec 2026 21:17:52 +0000</pubDate>
      <link>https://dev.to/pranay_raavi/part-1-before-you-turn-on-ccr-the-settings-that-matter-and-the-ones-that-bite-4gp5</link>
      <guid>https://dev.to/pranay_raavi/part-1-before-you-turn-on-ccr-the-settings-that-matter-and-the-ones-that-bite-4gp5</guid>
      <description>&lt;p&gt;&lt;em&gt;Cross-cluster replication takes a handful of API calls. The risk sits in the prerequisites, and in the settings you change when you aren't sure.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The API part of our proof of concept took an afternoon. The prerequisite list took weeks. This post is that list, plus every setting we touched and what it costs to get wrong.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Subscription.&lt;/strong&gt; CCR is a paid feature in Elastic's distribution. Confirm your tier covers both clusters.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Versions.&lt;/strong&gt; The follower cluster must run the same or a newer version than the leader, down to the patch level. Any minor version works within a major. Across majors, an 8.x follower can follow a 7.17+ leader, a 9.0 follower can follow 8.18+, and 9.1 or later can follow 8.19+. In a two-stream design, each cluster follows the other, so in practice both run the same version.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Soft deletes on every leader index.&lt;/strong&gt; They are on by default for indices created on 7.0 or later. Older indices without them must be reindexed before they can lead.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Remote cluster connectivity.&lt;/strong&gt; Follower nodes must reach the leader's transport layer (sniff mode, using seed nodes) or a single proxy address (proxy mode). Nodes also need the &lt;code&gt;remote_cluster_client&lt;/code&gt; role. It is a default role, but clusters with an explicit &lt;code&gt;node.roles&lt;/code&gt; list often leave it out.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Trust between clusters.&lt;/strong&gt; We used the same TLS certificates on both clusters, so the remote connection worked without separate credentials. Newer versions also offer API-key based remote cluster security.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Replication users and roles&lt;/strong&gt; on both clusters, with least privilege, unless certificate trust covers you.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;WAN capacity.&lt;/strong&gt; Remote recovery copies whole segment files between datacenters.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0wb20pp5fqwh6l9j7wy0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0wb20pp5fqwh6l9j7wy0.png" alt="Six prerequisite gates before replication: license, versions, soft deletes, connectivity, trust, users and roles." width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The settings we touched, and the risk of guessing
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Setting&lt;/th&gt;
&lt;th&gt;Why you touch it&lt;/th&gt;
&lt;th&gt;Risk if you guess&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;cluster.remote.&amp;lt;name&amp;gt;.seeds&lt;/code&gt; / &lt;code&gt;mode&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Defines the remote cluster. Dynamic, no restart.&lt;/td&gt;
&lt;td&gt;Seeds pinned to node IPs break when nodes are replaced. Prefer DNS names or proxy mode.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;index.soft_deletes.retention_lease.period&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;How long a follower can be offline and still catch up. Default 12h; we set 24h in the index template.&lt;/td&gt;
&lt;td&gt;Longer means the leader keeps more history: more disk and merge work. Shorter means more full re-copies after outages.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Follower read and write parameters (&lt;code&gt;max_read_request_operation_count&lt;/code&gt;, &lt;code&gt;max_outstanding_read_requests&lt;/code&gt;, &lt;code&gt;max_write_buffer_count&lt;/code&gt;, &lt;code&gt;max_write_buffer_size&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;Catch-up throughput. We raised the write buffer.&lt;/td&gt;
&lt;td&gt;Follower heap pressure, and bursts of read load on the leader.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ccr.indices.recovery.max_bytes_per_sec&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Throttles remote recovery for new followers.&lt;/td&gt;
&lt;td&gt;Too high saturates the WAN and leader disks in business hours; too low stretches the initial sync.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;indices.lifecycle.poll_interval&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;We lowered it in testing to watch ILM steps quickly.&lt;/td&gt;
&lt;td&gt;Extra work for the master. Put the default (10m) back in production.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;index.number_of_replicas&lt;/code&gt; on the follower&lt;/td&gt;
&lt;td&gt;The follower's replica count is local; replica changes on the leader don't replicate.&lt;/td&gt;
&lt;td&gt;A DR copy with no replicas is one node failure from red.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  If the cluster is already live
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Indices without soft deletes can't lead.&lt;/strong&gt; Reindex into new indices and cut over with an alias. Budget disk for both copies, plus a write freeze or a catch-up plan.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Static settings close indices.&lt;/strong&gt; Changing a static (non-dynamic) index setting requires closing the index. On a leader, a static change that the follower needs makes the follower close itself, apply it and reopen, which pauses both reads and replication on the DR side.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Existing indices need explicit followers.&lt;/strong&gt; Auto-follow handles only new indices, and creating a follower fails if an index with the same name already exists on the target. If the DR cluster already holds copies from snapshot restores, those have to go first, so the first CCR sync is a full copy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Role changes mean restarts.&lt;/strong&gt; Adding &lt;code&gt;remote_cluster_client&lt;/code&gt; to nodes with dedicated roles takes a rolling restart.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The initial sync is a project.&lt;/strong&gt; Following thousands of indices is a scheduled, throttled operation. Watch it with &lt;code&gt;_cat/recovery&lt;/code&gt;, where remote recoveries show up as type &lt;code&gt;snapshot&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The minimal sequence
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="c1"&gt;# On the follower cluster: define the remote
&lt;/span&gt;&lt;span class="no"&gt;PUT&lt;/span&gt; &lt;span class="n"&gt;_cluster&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;settings&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="s2"&gt;"persistent"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"cluster"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="s2"&gt;"remote"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;"east"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;"seeds"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"east-seed-1.example.internal:9300"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="no"&gt;GET&lt;/span&gt; &lt;span class="n"&gt;_remote&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;info&lt;/span&gt;

&lt;span class="c1"&gt;# Follow one existing index
&lt;/span&gt;&lt;span class="no"&gt;PUT&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;orders_east_202311&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;_ccr&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;follow&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="s2"&gt;"remote_cluster"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"east"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s2"&gt;"leader_index"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"orders_east_202311"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;# Follow every future index that matches
&lt;/span&gt;&lt;span class="no"&gt;PUT&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;_ccr&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;auto_follow&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;from_east&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="s2"&gt;"remote_cluster"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"east"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s2"&gt;"leader_index_patterns"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"orders_east_*"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;# Check
&lt;/span&gt;&lt;span class="no"&gt;GET&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;_ccr&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;stats&lt;/span&gt;
&lt;span class="no"&gt;GET&lt;/span&gt; &lt;span class="cm"&gt;/*/_ccr/info
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One habit from the proof of concept: define both remote clusters and both auto-follow patterns on both clusters, even though each cluster strictly needs only its own. Part 6 explains why that symmetry saved us.&lt;/p&gt;

&lt;h2&gt;
  
  
  Risks and precautions
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Test every setting on a staging pair with a production-sized index count. Behavior at 20 indices tells you little about 2,000.&lt;/li&gt;
&lt;li&gt;Write down every non-default setting and apply it to both clusters through templates and config as code. CCR doesn't carry cluster settings or templates.&lt;/li&gt;
&lt;li&gt;Size the retention lease to your longest plausible outage, then budget leader disk for it.&lt;/li&gt;
&lt;li&gt;Throttle remote recovery and run the first sync off-hours.&lt;/li&gt;
&lt;li&gt;Plan your upgrade path before you replicate. The version rules decide it (Part 8).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnzawc0k9topzyml81cjp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnzawc0k9topzyml81cjp.png" alt="A retention-lease dial set in its safe band, with the words Measure at production scale." width="799" height="294"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Part 3 of 8 in &lt;a href="https://dev.to/pranay_raavi/series/47931"&gt;Elasticsearch Replication &amp;amp; DR Field Notes&lt;/a&gt; . Previous: Part 2, the two-stream architecture. Next: Part 4, Alias or Index Pattern?&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.elastic.co/docs/deploy-manage/tools/cross-cluster-replication" rel="noopener noreferrer"&gt;Elastic docs: Cross-cluster replication (version compatibility, soft deletes, replication mechanics)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>elasticsearch</category>
      <category>devops</category>
      <category>database</category>
      <category>sre</category>
    </item>
    <item>
      <title>Part 2: "Bidirectional Elasticsearch Replication Doesn't Exist. Here's the Architecture That Does."</title>
      <dc:creator>Pranay Ravi</dc:creator>
      <pubDate>Sun, 06 Dec 2026 21:12:12 +0000</pubDate>
      <link>https://dev.to/pranay_raavi/part-2-bidirectional-elasticsearch-replication-doesnt-exist-heres-the-architecture-that-does-3ho9</link>
      <guid>https://dev.to/pranay_raavi/part-2-bidirectional-elasticsearch-replication-doesnt-exist-heres-the-architecture-that-does-3ho9</guid>
      <description>&lt;p&gt;&lt;em&gt;Cross-cluster replication is active-passive per index. Two-way replication is two one-way streams and a naming rule, and Elastic's own 9.x disaster recovery tutorial builds it the same way.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;When we evaluated cross-cluster replication (CCR) to replace snapshot-based DR (Part 1), the requirement was "bidirectional": both datacenters take writes, and both see all the data. The first finding of the proof of concept was that CCR doesn't do that. The second was that you can build it anyway, once you accept what it is.&lt;/p&gt;

&lt;h2&gt;
  
  
  CCR in two minutes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Replication is set up per index: a &lt;strong&gt;leader&lt;/strong&gt; index on a remote cluster and a &lt;strong&gt;follower&lt;/strong&gt; index on the local cluster.&lt;/li&gt;
&lt;li&gt;It is pull-based. Each follower shard pulls operations from its leader shard, so a follower has the same shard count as its leader.&lt;/li&gt;
&lt;li&gt;A new follower bootstraps by copying segment files from the leader (remote recovery), then replays individual operations that the leader keeps through soft deletes.&lt;/li&gt;
&lt;li&gt;Followers are read-only. Mappings and most settings follow the leader.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Auto-follow patterns&lt;/strong&gt; create followers automatically for new leader indices that match a pattern. Existing indices need explicit followers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;CCR supports several topologies: one-way (production to DR), bidirectional, chained (A to B to C), broadcast (one leader to many followers), and consolidation (many sites into one reporting cluster).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmna7mjf8l9moj8uxwgzn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmna7mjf8l9moj8uxwgzn.png" alt="Five CCR topologies: one-way, bidirectional, chained, broadcast and consolidation." width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The catch: no index is writable in two places
&lt;/h2&gt;

&lt;p&gt;A follower index rejects writes. The same index can't be a leader in both clusters, and CCR has no conflict resolution. In CCR, "bidirectional" means each cluster holds some leader indices and some follower indices. It is two active-passive streams running in opposite directions.&lt;/p&gt;

&lt;h2&gt;
  
  
  The design: two one-way streams and a naming rule
&lt;/h2&gt;

&lt;p&gt;Every index name carries the site that writes it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;orders_east_202311&lt;/code&gt; is written at East, which leads it; West follows it.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;orders_west_202311&lt;/code&gt; is written at West, which leads it; East follows it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each cluster gets one auto-follow pattern that points at the other cluster and matches only the other site's suffix:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# On Cluster West: follow everything East writes
PUT /_ccr/auto_follow/from_east
{
  "remote_cluster": "east",
  "leader_index_patterns": ["orders_east_*"]
}

# On Cluster East: the mirror image
PUT /_ccr/auto_follow/from_west
{
  "remote_cluster": "west",
  "leader_index_patterns": ["orders_west_*"]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Applications at each site write only to indices with their own suffix and read from &lt;code&gt;orders_*&lt;/code&gt;. That pattern matches both the local leader indices and the replicated followers, so every site has a global read view.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frfl3ipbt984rbszr1erb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frfl3ipbt984rbszr1erb.png" alt="Each cluster leads its own site's indices and follows the other site's; apps write locally and read across both." width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Elastic's current tutorial does the same thing
&lt;/h3&gt;

&lt;p&gt;Elastic's bi-directional disaster recovery tutorial for 9.x uses data streams instead of monthly indices, but the architecture is the same. Each cluster runs an auto-follow pattern against the other, uses &lt;code&gt;leader_index_exclusion_patterns&lt;/code&gt; to avoid replicating followers back (recursion), and uses &lt;code&gt;follow_index_pattern&lt;/code&gt; to rename replicated backing indices with a "replicated from" suffix. Logstash writes to both clusters' hosts, and queries search across both data streams. The tutorial also notes that update and delete by query can only run on the leader. In other words, the site suffix moved from the application into the follow pattern, and nothing else changed.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the design buys you
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;No write failover.&lt;/strong&gt; If East goes down, West keeps writing to its own indices. East's data, up to the last replicated operation, stays readable at West.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A DR site that is always open for reads.&lt;/strong&gt; Reporting and ad hoc queries can run there instead of competing with production indexing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lag in seconds, not hours.&lt;/strong&gt; Followers pull continuously instead of waiting for an hourly restore.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Regional indices.&lt;/strong&gt; Keeping each site's data in its own indices gives you independent retention and sizing per site, contains a bad deploy to one site's indices, and lets you replicate only the index families that need a global view.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What it can't do
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Resolve conflicts.&lt;/strong&gt; A document belongs to the site that wrote it, so updates and deletes must go to that site. Elastic's docs describe bi-directional replication as particularly useful for index-only workloads, where documents are immutable.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hide ownership from the application.&lt;/strong&gt; If your app updates documents, store the owner site in the document (a field, or a site prefix in &lt;code&gt;_id&lt;/code&gt;) and route updates there. An update sent to the wrong site fails against a follower, and a "fix" that writes a new copy locally creates two versions of the truth.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Save in-flight writes on site loss.&lt;/strong&gt; Operations the other site hasn't pulled yet are stranded until the failed site comes back (Part 7).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Replicate the whole cluster.&lt;/strong&gt; Users, dashboards, templates and policies don't travel (Part 6).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Plan the first sync like a migration. Our proof of concept covered about 2,000 indices, and following all of them took up to about 10 hours of remote recovery.&lt;/p&gt;

&lt;h2&gt;
  
  
  How applications should use it
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Write&lt;/strong&gt; only to your own site's indices, by exact name or through a site-local write alias. Never write across sites.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Read&lt;/strong&gt; through an index pattern or a read alias that spans both sites.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Update and delete&lt;/strong&gt; by routing to the owner site.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Authenticate&lt;/strong&gt; as a per-site application user that can only create and write its own site's indices (Part 4).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stay local.&lt;/strong&gt; Clients talk to the cluster in their own datacenter.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Risks and precautions
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The naming rule is the entire replication contract. One mis-named index never matches the other site's pattern and silently never replicates.&lt;/li&gt;
&lt;li&gt;With no conflict resolution, keep two-way replication for append-mostly data, or enforce document ownership in the application.&lt;/li&gt;
&lt;li&gt;Auto-follow ignores indices that already exist. Plan explicit followers and the initial sync.&lt;/li&gt;
&lt;li&gt;Prevent loops: a pattern must never match follower indices on its own cluster. Exclusion patterns help on newer versions.&lt;/li&gt;
&lt;li&gt;Check your subscription. CCR is a paid feature in Elastic's distribution.&lt;/li&gt;
&lt;li&gt;You need to remove/ control write privileges on your DR site to accidentally write to the follower ,this can be done in a few ways at the Elastic level and also in the CI/CD config management &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fm7353nt1pvng0u9wsy7v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fm7353nt1pvng0u9wsy7v.png" alt="Two clusters joined by two one-way arrows with the words Every index has exactly one writer." width="799" height="294"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Part 2 of 8 in &lt;a href="https://dev.to/pranay_raavi/series/47931"&gt;Elasticsearch Replication &amp;amp; DR Field Notes&lt;/a&gt;. Previous: Part 1, Elasticsearch DR the Hard Way. Next: Part 3, Before You Turn On CCR.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.elastic.co/docs/deploy-manage/tools/cross-cluster-replication" rel="noopener noreferrer"&gt;Elastic docs: Cross-cluster replication&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.elastic.co/docs/deploy-manage/tools/cross-cluster-replication/bi-directional-disaster-recovery" rel="noopener noreferrer"&gt;Elastic docs: Bi-directional disaster recovery&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.elastic.co/docs/deploy-manage/tools/cross-cluster-replication/ccr-tutorial-initial-setup" rel="noopener noreferrer"&gt;Elastic docs: Bi-directional DR, initial setup&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>elasticsearch</category>
      <category>architecture</category>
      <category>devops</category>
      <category>sre</category>
    </item>
    <item>
      <title>Part 1: Elasticsearch DR the Hard Way: Hourly Snapshots, NAS Replication, and a Huge Lag</title>
      <dc:creator>Pranay Ravi</dc:creator>
      <pubDate>Sun, 06 Dec 2026 20:50:48 +0000</pubDate>
      <link>https://dev.to/pranay_raavi/part-1-elasticsearch-dr-the-hard-way-hourly-snapshots-nas-replication-and-a-huge-lag-3mdg</link>
      <guid>https://dev.to/pranay_raavi/part-1-elasticsearch-dr-the-hard-way-hourly-snapshots-nas-replication-and-a-huge-lag-3mdg</guid>
      <description>&lt;p&gt;A few years back, Elasticsearch disaster recovery worked like this: two datacenters, an active cluster and a passive one, each with their data nodes and masters, serving an application that loaded and searched a handful of index families. There was no cross-cluster replication. The passive site was kept current by snapshots, filesystem replication, and cron.&lt;br&gt;
This series covers what I learned taking that setup from snapshot-based DR to two-way replication, including the parts no tutorial warns you about. Part 1 starts where I started.&lt;/p&gt;

&lt;h2&gt;
  
  
  How the snapshot pipeline worked
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Snapshot on the primary, hourly.&lt;/strong&gt; A Curator job took one snapshot per index prefix into a shared-filesystem repository. The repository was an NFS export from a NAS, mounted on every node at the same path and allowed through &lt;code&gt;path.repo&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Replicate the NAS, not the cluster.&lt;/strong&gt; The NAS took periodic ZFS snapshots of that dataset and shipped them incrementally to the NAS in the DR datacenter.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Register the same repository at DR, read-only.&lt;/strong&gt; DR saw every snapshot the primary took, once the NAS replication landed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Restore at DR, hourly, offset from the snapshot job.&lt;/strong&gt; A second Curator job closed the matching indices, restored the latest successful snapshot, and reopened them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Check.&lt;/strong&gt; Compare doc counts per index family on both sides with &lt;code&gt;_stats&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkrkybeud7jjvd7op3buo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkrkybeud7jjvd7op3buo.png" alt=" " width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Snapshot pipeline from primary cluster through NAS replication to a DR restore job, with hours of lag.&lt;/p&gt;

&lt;p&gt;On paper it is clean: every component is a documented feature. In production, the time went into the gaps between components.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it cost
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Lag measured in hours.&lt;/strong&gt; Two hourly schedules with NAS replication in between meant DR was never current. We planned for 200 to 600 minutes behind. That is your recovery point in a datacenter loss, and nobody enjoys saying it out loud.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A DR cluster you couldn't use.&lt;/strong&gt; Restoring over an existing index requires closing it, so our DR indices spent part of every hour closed. The passive cluster couldn't safely serve reads, and hardware sized for production sat idle.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Storage that only grew.&lt;/strong&gt; Snapshots are incremental, but the repository grows with churn. Resizing the NAS volume was close to a full re-sync between sites.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Moving parts that failed quietly.&lt;/strong&gt; Curator failed now and then, NAS replication was hard to observe, and a missed hour showed up only as a bigger gap the next hour.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reversal took a weekend.&lt;/strong&gt; Switching sites was an 18-step runbook: stop data loads, lock the loader accounts, confirm both sides matched, stop the snapshot jobs, flip the primary repository to read-only and the DR repository to read-write, stop and reverse the NAS tasks, move dashboards and saved searches by hand, re-enable everything in the other direction, and verify the snapshots matched. We scheduled it across Saturday to Monday. Reversing replication was, in effect, always a full resync.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Security had its own pipeline.&lt;/strong&gt; Users and roles live in the security index, which needed a separate hourly snapshot-and-restore flow. That story gets its own post in Part 6.&lt;/p&gt;

&lt;h2&gt;
  
  
  The monitoring we bolted on
&lt;/h2&gt;

&lt;p&gt;With no native replication status, we built our own signals and sent them to the monitoring stack:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Heartbeat document.&lt;/strong&gt; A small index on the primary holds the site name and a timestamp, updated on a schedule. At DR, lag is now minus the newest heartbeat it can see. One number, easy to alert on.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Doc-count difference&lt;/strong&gt; per index family between sites.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Error scraping&lt;/strong&gt; on the Curator log.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Red-index count&lt;/strong&gt; on both clusters.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Job-liveness metrics&lt;/strong&gt;, so a monitoring script that stopped running raised an alert instead of going quiet.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The heartbeat survived every architecture change that followed. If you take one thing from this post, take that: write a timestamp at the source, read it at the destination, alert on the difference.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this looks like today, and why snapshots still matter
&lt;/h2&gt;

&lt;p&gt;Snapshot lifecycle management (SLM) replaces Curator for scheduled snapshots, and object storage (S3, GCS, Azure Blob) replaces the NAS as a repository both clusters can read. Snapshot-based DR is still a reasonable choice when a recovery point of hours is acceptable, when you need point-in-time recovery anyway, or when the clusters run different major versions, since a snapshot restores into the next major version.&lt;/p&gt;

&lt;p&gt;Even after we moved to cross-cluster replication, snapshots stayed. &lt;strong&gt;Replication is not a backup.&lt;/strong&gt; A bad bulk delete or a corrupting write reaches the follower in seconds. Only a snapshot takes you back to before it happened.&lt;/p&gt;

&lt;h2&gt;
  
  
  Risks and precautions
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Your recovery point is the sum of every schedule and transfer in the chain, not the snapshot interval. Measure it with a heartbeat instead of computing it.&lt;/li&gt;
&lt;li&gt;A restore-based DR cluster is cold. Don't promise reads from it.&lt;/li&gt;
&lt;li&gt;Rehearse the switch. A runbook nobody has run is a hypothesis.&lt;/li&gt;
&lt;li&gt;Snapshot the security state separately, and test the restore.&lt;/li&gt;
&lt;li&gt;Keep taking snapshots after you adopt replication. They are your only undo.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fe4r0abmmdtn4v1rrfi7m.png" alt=" " width="799" height="294"&gt;
&lt;/h2&gt;

&lt;h2&gt;
  
  
  &lt;em&gt;Part 1 of 8 in &lt;a href="https://dev.to/pranay_raavi/series/47931"&gt;Elasticsearch Replication &amp;amp; DR Field Notes&lt;/a&gt;. Next: Part 2, Bidirectional Elasticsearch Replication Doesn't Exist. Here's the Architecture That Does.&lt;/em&gt; 
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.elastic.co/docs/deploy-manage/tools/cross-cluster-replication" rel="noopener noreferrer"&gt;Elastic docs: Cross-cluster replication&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>elasticsearch</category>
      <category>freenas</category>
      <category>elasticcurator</category>
    </item>
    <item>
      <title>Sharding, Explored: An Interview With AI That Started on a Reddit Thread</title>
      <dc:creator>Pranay Ravi</dc:creator>
      <pubDate>Sat, 28 Nov 2026 21:36:19 +0000</pubDate>
      <link>https://dev.to/pranay_raavi/sharding-explored-an-interview-with-ai-that-started-on-a-reddit-thread-4anc</link>
      <guid>https://dev.to/pranay_raavi/sharding-explored-an-interview-with-ai-that-started-on-a-reddit-thread-4anc</guid>
      <description>&lt;p&gt;I came across a thread on r/Database and couldn't stop thinking about it. The author runs an on-prem PostgreSQL 14 deployment: ~40 TB logical, ~500 billion rows of IoT telemetry, partitioned by business day, with a primary and read replica in separate data centres. Performance today is fine. The question is whether to shard Postgres, move to ClickHouse, or reach for something else as the system grows.&lt;/p&gt;

&lt;p&gt;The detail that matters isn't the size — it's the workload shape. The queries are &lt;strong&gt;point lookups&lt;/strong&gt;: every column for one device over a 4–5 day range, up to a million times an hour, each under 100 ms. That's OLTP, not analytics. Most of the confident answers in the thread assumed otherwise.&lt;/p&gt;

&lt;p&gt;I run Oracle, Aurora PostgreSQL, MongoDB, and Elasticsearch across a large AWS estate, so I used the thread as a springboard: I interviewed an AI across every sharding model I touch, pushing hardest on the parts I already had opinions about. What follows is that conversation, edited — the questions and the judgment are mine.&lt;/p&gt;

&lt;h2&gt;
  
  
  Is sharding just partitioning with pg_partman?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Q.&lt;/strong&gt; When people say "shard Postgres," is that the same as partitioning a big table with pg_partman?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A.&lt;/strong&gt; No — the axis is &lt;em&gt;location&lt;/em&gt;. Partitioning (pg_partman's job) splits one logical table into child tables on the &lt;strong&gt;same server and disk&lt;/strong&gt;; it automates partition creation and retention drops and never crosses a machine boundary. Sharding splits rows across &lt;strong&gt;independent servers&lt;/strong&gt;, each with its own CPU, RAM, and disk. Postgres has no native sharding — you reach for Citus, application-level routing, or &lt;code&gt;postgres_fdw&lt;/code&gt;. Partitioning buys single-node maintainability (partition pruning, cheap retention via &lt;code&gt;DROP TABLE&lt;/code&gt;); sharding buys capacity. They compose: each shard is usually time-partitioned internally.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ftafpibumxciosg76yd66.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ftafpibumxciosg76yd66.png" alt="Partitioning keeps child tables on one server; sharding splits rows across independent servers." width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;My take.&lt;/strong&gt; The OP was &lt;em&gt;already&lt;/em&gt; partitioning; sharding by &lt;code&gt;device_id&lt;/code&gt; is a categorically heavier move, not an extension of it. For an indexed point-lookup workload, data size at rest doesn't slow queries — partition pruning does the work regardless of total size. The real pain at 40 TB is operational: backup, restore, and major-version upgrades. "Big and nervous" is not a workload description. Size and access pattern are different axes, and conflating them is how teams talk themselves into migrations they don't need.&lt;/p&gt;

&lt;h2&gt;
  
  
  So is ClickHouse the answer?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Q.&lt;/strong&gt; Half the thread says move to ClickHouse. What is it, and does it fit?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A.&lt;/strong&gt; ClickHouse is a columnar OLAP engine. A row store (Postgres) keeps a row's columns contiguous — ideal for fetching or updating whole records by key. A column store keeps each column contiguous and compressed, so a scan reads only the columns it needs. That, plus a sort key, is why aggregations fly. The OP is tempted by two numbers: 16× compression (vs their 5×) and native sharding. But their access pattern is point lookups — reconstruct &lt;strong&gt;all&lt;/strong&gt; columns of one row — which scatters reads across separate column files. The right sort key makes it tolerable, but you're fighting the engine and giving up transactions and efficient single-row operations.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6wa1aa5vz0svgx6mzlvy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6wa1aa5vz0svgx6mzlvy.png" alt="A point lookup jumps to a few adjacent rows; an aggregation scan sweeps one column across billions." width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;My take.&lt;/strong&gt; Point lookup = index-jump to a few adjacent rows. Aggregation scan = sweep one column across billions. ClickHouse is built for the second; this workload is the first. Compression and native sharding are the &lt;em&gt;wrong reasons&lt;/em&gt; to pick an OLAP engine for an OLTP shape. Reach for ClickHouse exactly where the OP said they have no need: large aggregations over append-only history.&lt;/p&gt;

&lt;h2&gt;
  
  
  Once you shard Postgres, how do standby and DR work?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Q.&lt;/strong&gt; After sharding, is one shard's data replicated to another node as a secondary? How do HA and DR work?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A.&lt;/strong&gt; Sharding and replication are &lt;strong&gt;orthogonal&lt;/strong&gt;. Sharding alone gives zero redundancy. Each shard gets its &lt;strong&gt;own&lt;/strong&gt; standby via ordinary streaming replication; shards don't back each other up. The coordinator (which holds the shard map) needs its own standby too. DR's catch: shards replicate independently and asynchronously, so a cross-region copy is &lt;strong&gt;not&lt;/strong&gt; a globally consistent snapshot — a cross-shard 2PC transaction can be committed on one shard's replica and not another's. A regional failover becomes an orchestration problem (promote every shard plus the coordinator), and point-in-time recovery means coordinating a recovery target across all shards.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxpv4fekmzig87f9ykvn5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxpv4fekmzig87f9ykvn5.png" alt="Each shard gets its own standby; cross-region DR replicas lag independently, so no globally consistent snapshot." width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;My take.&lt;/strong&gt; This is the hidden tax of DIY sharding, and it doesn't show up in a proof of concept. One primary/standby pair I can reason about completely; N shards plus a coordinator — each its own failover domain — explodes the operational surface. The cross-shard consistency gap is the one I'd lose sleep over: DR looks fine until you fail over mid-transaction and the shards disagree. Budget as much design time for failover and restore as for the sharding itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  The managed option: Amazon Aurora Limitless
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Q.&lt;/strong&gt; If I don't want to hand-roll sharding, how does Amazon's own sharded Postgres — Aurora Limitless — handle standby and DR?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A.&lt;/strong&gt; Strong in-region, weaker cross-region. &lt;strong&gt;Storage:&lt;/strong&gt; six copies across three Availability Zones, so durability is automatic. &lt;strong&gt;Compute:&lt;/strong&gt; you choose 0, 1, or 2 standbys per node at shard-group creation for fast failover. Cross-shard writes use two-phase commit, and Aurora recovers in-flight prepared transactions on failover — no half-committed cross-shard write. It carries a 99.99% availability SLA. &lt;strong&gt;The catch:&lt;/strong&gt; Aurora Global Database — the usual cross-region mechanism (~5 s RPO, sub-minute RTO) — is &lt;strong&gt;not supported&lt;/strong&gt; for Limitless, and a Limitless cluster can't be a replication source. Cross-region DR falls back to copying a cluster snapshot and restoring: coarse, manual, higher RPO and RTO.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9dv2g6eezzqkmq36osyv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9dv2g6eezzqkmq36osyv.png" alt="Aurora Limitless: strong in-region HA, but no Global Database, so cross-region DR is snapshot-based." width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;My take.&lt;/strong&gt; This is the finding that would most shape my decision — and I only trust it because I checked the live AWS docs rather than memory; these managed-service limits shift between releases. In-region, Limitless removes the hardest parts of DIY sharding: coordinator HA and cross-shard transaction recovery are handled for me. But losing Global Database is a real DR downgrade — the failover/failback pattern I rely on elsewhere simply doesn't apply, so a Limitless cluster needs a snapshot-based runbook. If low-RPO cross-region DR is a hard requirement, that gap is where the risk concentrates. Verify it at build time.&lt;/p&gt;

&lt;h2&gt;
  
  
  A real schema isn't one big table
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Q.&lt;/strong&gt; My databases mix partitioned fact tables, several metadata tables, config tables, and transactional logging tables. How does that survive sharding?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A.&lt;/strong&gt; Sort every table into one of three placements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Distributed (sharded)&lt;/strong&gt; — large tables split by a shard key: your fact tables and high-volume logs. Time partitioning composes within each shard.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reference&lt;/strong&gt; — small, read-heavy tables that everything joins against (metadata, most config): a &lt;strong&gt;full copy on every node&lt;/strong&gt; so joins stay local; writes cost more because they touch every copy (2PC).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Local&lt;/strong&gt; — small, self-contained tables that live on one node.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The make-or-break concept is &lt;strong&gt;colocation&lt;/strong&gt;: related sharded tables must share the shard key so their matching shards sit together and joins stay local. The constraints you inherit are the real work — foreign keys only across colocated tables or to reference tables, unique keys must include the shard key, and cross-shard transactions run through 2PC.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmbwj1qb9l8pqhbe2uyw8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmbwj1qb9l8pqhbe2uyw8.png" alt="Sorting a mixed schema: sharded tables, reference tables copied to every node, and local tables." width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;My take.&lt;/strong&gt; The shift is from "how do I shard my database" to "what role does each table play, so where should its rows live." Then a messy schema sorts itself quickly: big and keyed by the common column → sharded and colocated; small and universally joined → reference; everything else → local. Log tables are the cleanest to shard — append-only, no joins to colocate, time partitioning already handles retention. Most of the migration effort isn't the big tables; it's reconciling the foreign keys and unique constraints that quietly assumed a single node.&lt;/p&gt;

&lt;h2&gt;
  
  
  How is MongoDB different — and is data copied between shards?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Q.&lt;/strong&gt; How does Mongo sharding differ from Postgres, and is data replicated between the shards?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A.&lt;/strong&gt; Between shards, no — each shard holds a disjoint subset. Within a shard, always: &lt;strong&gt;every MongoDB shard is itself a replica set&lt;/strong&gt;. Replication is the native building block, not a bolt-on — the biggest contrast with Postgres, where you assemble the two yourself. Three tiers: stateless &lt;code&gt;mongos&lt;/code&gt; routers (the coordinator), a config-server replica set holding the chunk map (the metadata), and the shards. Mongo auto-rebalances via a background balancer (Citus is manual). It pursues locality through &lt;strong&gt;embedding&lt;/strong&gt; — denormalize related data into one document so it lives on one shard — versus Postgres colocation and reference tables. DR is just placing replica-set members across regions; failover is the ordinary election, uniform on every shard.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fk7gvrrw3gomycsjfo7hr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fk7gvrrw3gomycsjfo7hr.png" alt="Every MongoDB shard is itself a replica set; replication is within a shard, not between shards." width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;My take.&lt;/strong&gt; Let me be precise, because two things are easy to conflate: data replicates &lt;em&gt;within&lt;/em&gt; each shard (to its secondaries), never &lt;em&gt;between&lt;/em&gt; shards — the shards hold disjoint data. And that within-shard replication isn't optional: MongoDB requires every production shard to be a replica set. That's exactly the part I'd push back on operationally. A production sharded cluster isn't one system, it's &lt;em&gt;many&lt;/em&gt; — a replica set per shard, plus a config-server replica set, plus the mongos routers. Several clusters to patch, back up, monitor, and fail over — the cost that never shows up in a demo. The upside is that geographic DR is uniform (place replica-set members across regions) and the thing I already operate &lt;em&gt;is&lt;/em&gt; the shard. But if the appeal of a model is "one cluster that manages itself," Mongo's many-replica-sets topology sits at the opposite end of that spectrum — a fair reason to prefer something like Elasticsearch, where the cluster is a single self-balancing unit. The trade Mongo extracts for its locality is the join: you design around it by embedding at write time.&lt;/p&gt;

&lt;h2&gt;
  
  
  The model I like most: Elasticsearch's elastic shards
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Q.&lt;/strong&gt; Of all of these, I like Elasticsearch's model best — primaries and replicas, per index or cluster-wide, replicas that serve traffic, and no index-tuning guesswork. Joins between indices are bad; if I must, I join in the application on a common key. Am I right to like it this much?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A.&lt;/strong&gt; Well-founded, with two asterisks. The real wins: Elasticsearch decouples the two axes Postgres fuses — primaries are the partitioning knob, replicas the replication knob, independently dialable — and replicas aren't passive standbys; they actively serve searches, so scaling them buys redundancy &lt;strong&gt;and&lt;/strong&gt; read throughput in one dynamic setting. The operational self-management beats babysitting per-shard Postgres replication. And index-free, tokenized search inverts the Postgres game: everything is indexed, and the analyzer pipeline gives linguistic matching for free. &lt;strong&gt;Asterisk 1:&lt;/strong&gt; only replicas are elastic — primary count is fixed at index creation, so raising it means a reindex (oversharding is the classic footgun). &lt;strong&gt;Asterisk 2:&lt;/strong&gt; the tuning work doesn't vanish, it moves — from reactive query-and-index tuning to getting mappings and analyzers right up front, which is harder to change later. It earns the elegance by relaxing what a system of record provides: no multi-document ACID, no real joins, near-real-time (refresh-based) rather than immediate visibility.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;My take.&lt;/strong&gt; The application-side join on a common key is the correct, idiomatic answer — just go in knowing it has no cross-index transactional consistency and won't scale like a colocated relational join. The idiomatic next step when it hurts isn't "join better," it's to denormalize at write time so the join mostly disappears — the same instinct as Mongo embedding. What I love is what you'd love: the operational smoothness, the shard management the cluster just handles, and not having to guess indexes. But I keep the asterisk visible — it's superior &lt;strong&gt;at its job&lt;/strong&gt; (search, analytics, horizontal read scale), not superior in general.&lt;/p&gt;

&lt;h2&gt;
  
  
  The architecture, side by side
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Dimension&lt;/th&gt;
&lt;th&gt;Postgres + Citus&lt;/th&gt;
&lt;th&gt;Aurora Limitless&lt;/th&gt;
&lt;th&gt;MongoDB&lt;/th&gt;
&lt;th&gt;Elasticsearch&lt;/th&gt;
&lt;th&gt;ClickHouse&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Distribution unit&lt;/td&gt;
&lt;td&gt;Shard (hash/range of key)&lt;/td&gt;
&lt;td&gt;Shard (hash of key)&lt;/td&gt;
&lt;td&gt;Chunk (shard-key range)&lt;/td&gt;
&lt;td&gt;Primary shard (Lucene index)&lt;/td&gt;
&lt;td&gt;Shard (sharding key)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Replication&lt;/td&gt;
&lt;td&gt;Per-node streaming (you add it)&lt;/td&gt;
&lt;td&gt;6-way storage + 0–2 compute standbys&lt;/td&gt;
&lt;td&gt;Replica set per shard (native)&lt;/td&gt;
&lt;td&gt;Replica shards, live, serve reads&lt;/td&gt;
&lt;td&gt;ReplicatedMergeTree per shard&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rebalancing&lt;/td&gt;
&lt;td&gt;Manual (&lt;code&gt;rebalance_table_shards&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;Managed&lt;/td&gt;
&lt;td&gt;Automatic balancer&lt;/td&gt;
&lt;td&gt;Automatic shard allocation&lt;/td&gt;
&lt;td&gt;Manual&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Routing / metadata&lt;/td&gt;
&lt;td&gt;Coordinator&lt;/td&gt;
&lt;td&gt;Transaction routers (managed)&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;mongos&lt;/code&gt; + config-server RS&lt;/td&gt;
&lt;td&gt;Any node (cluster state)&lt;/td&gt;
&lt;td&gt;Distributed table / cluster config&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cross-shard txn&lt;/td&gt;
&lt;td&gt;2PC&lt;/td&gt;
&lt;td&gt;2PC, recovered on failover&lt;/td&gt;
&lt;td&gt;Multi-doc txn (4.2+)&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;td&gt;Limited&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cross-region DR&lt;/td&gt;
&lt;td&gt;Per-shard replica (DIY)&lt;/td&gt;
&lt;td&gt;Snapshot copy (no Global DB)&lt;/td&gt;
&lt;td&gt;Replica-set member placement&lt;/td&gt;
&lt;td&gt;Cross-cluster replication&lt;/td&gt;
&lt;td&gt;Replication / backup&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Join strategy&lt;/td&gt;
&lt;td&gt;Colocation + reference tables&lt;/td&gt;
&lt;td&gt;Colocation + reference tables&lt;/td&gt;
&lt;td&gt;Embed / app-side&lt;/td&gt;
&lt;td&gt;App-side / denormalize&lt;/td&gt;
&lt;td&gt;Mostly denormalize&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Consistency / visibility&lt;/td&gt;
&lt;td&gt;Strong, immediate&lt;/td&gt;
&lt;td&gt;Strong, immediate&lt;/td&gt;
&lt;td&gt;Tunable read/write concern&lt;/td&gt;
&lt;td&gt;Near-real-time (refresh)&lt;/td&gt;
&lt;td&gt;Eventually consistent inserts&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Architectural areas worth probing further
&lt;/h2&gt;

&lt;p&gt;A short map for anyone taking this past the blog-post stage:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Shard-key choice and skew.&lt;/strong&gt; Hashed keys spread writes evenly but kill range scans; ranged keys enable pruning but risk hot ranges. A monotonic key (timestamp, sequence) sends every new write to the last shard — the classic hotspot.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rebalancing and online data movement.&lt;/strong&gt; Adding a shard means moving data: Mongo chunk migration and Elasticsearch shard relocation are throttled background work; Citus shard moves are operator-driven. All of it competes with live traffic.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The router/coordinator as bottleneck and SPOF.&lt;/strong&gt; Stateless &lt;code&gt;mongos&lt;/code&gt; scale out trivially; a Citus coordinator needs its own HA and a connection-pooling layer (PgBouncer) in front of fan-out queries.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cross-shard transactions.&lt;/strong&gt; 2PC adds latency and a prepared-transaction recovery path you must test; the cheapest distributed transaction is the one your data model avoids.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Backup and restore topology.&lt;/strong&gt; Per-shard snapshots, consistent recovery targets across shards, and crash-consistent multi-volume snapshots are their own design problem at scale.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Observability.&lt;/strong&gt; Per-shard metrics, replica lag per shard, balancer queue depth, and hot-shard detection — a single cluster-wide dashboard hides the shard that's on fire.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Capacity and shard sizing.&lt;/strong&gt; Keep shards in a sane size band; oversharding wastes heap and metadata, undersharding limits parallelism. Elasticsearch's own guidance (tens of GB per shard) exists for exactly this reason.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Where I land: the conservation law of sharding
&lt;/h2&gt;

&lt;p&gt;One pattern falls out of every system here: &lt;strong&gt;each model makes cross-partition work cheap by making something else your problem.&lt;/strong&gt; Citus gives you relational joins but makes you choose a shard key and colocate. Aurora Limitless hands you managed in-region HA but takes away Global Database. MongoDB and Elasticsearch give you effortless elastic distribution but hand the join back to your application, nudging you to denormalize at write time. Nobody escapes the trade — they relocate it: to the shard key, the mapping, the ingestion pipeline, or the app.&lt;/p&gt;

&lt;p&gt;So why does Elasticsearch win for me on the axes I care about — operational smoothness and index-free querying? The same thing that makes it that good is why it hands the join back: it moved the hard decisions to write time and kept the read path simple. For a decide-it-once design temperament over continuous reactive tuning, that's a trade I keep wanting to make. But I keep my source of truth in the thing that will still say no to a half-committed transaction. These systems coexist as &lt;strong&gt;layers, not rivals&lt;/strong&gt;: a relational or document store as the system of record (correctness, transactions, relationships), and Elasticsearch as the search/analytics tier fed from it by change data capture. Elasticsearch gets its elastic-replica elegance precisely &lt;strong&gt;because&lt;/strong&gt; something upstream is holding the ACID line.&lt;/p&gt;

&lt;p&gt;The lens I'd offer anyone staring at a sharding decision: stop asking which model is best, and start asking which guarantee you refuse to give up. That answer — not the row count — tells you where the cost is allowed to land.&lt;/p&gt;

&lt;h2&gt;
  
  
  How you found this — and how I research with AI
&lt;/h2&gt;

&lt;p&gt;You probably arrived here from a search or a shared link, chasing the same question that pulled me in. That's how I learn new topics now, and the method matters as much as the answer. I didn't start from a course — I started from a real artifact (a messy 40 TB Reddit thread) and used the AI as an interview subject, not an oracle: explain, push back with what I know, make it defend the parts that sound too neat, and verify the one answer that could go stale (Limitless and Global Database) against the live vendor docs rather than trusting recall. The AI is fast and broad; my job is judgment, production scars, and skepticism.&lt;/p&gt;

&lt;p&gt;Four habits if you want to try it: anchor on something real (a concrete scenario forces concrete answers); interrogate rather than accept (ask why, ask what it trades away, ask where it breaks); verify anything time-sensitive — versions, limits, pricing, managed-service features — against primary sources; and translate each answer back through your own experience, because that's what turns information into understanding. Writing it up is the test of whether I actually learned it.&lt;/p&gt;

&lt;p&gt;I write about the systems I run day to day — this is one of a series.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources &amp;amp; further reading
&lt;/h2&gt;

&lt;p&gt;Every claim here is grounded in primary documentation. One caveat on method: managed-service limits (Aurora Limitless especially) shift between releases, so verify against the live docs before you design around them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The original thread&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.reddit.com/r/Database/comments/1tn2469/40_tb_postgresql_onprem_sharding_vs_clickhouse_vs/" rel="noopener noreferrer"&gt;r/Database — "40 TB PostgreSQL on-prem — sharding vs ClickHouse vs something else for a 500B-row time-series workload"&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Partitioning and Postgres sharding (Citus)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.postgresql.org/docs/current/ddl-partitioning.html" rel="noopener noreferrer"&gt;PostgreSQL — Table Partitioning&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/pgpartman/pg_partman" rel="noopener noreferrer"&gt;pg_partman&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.citusdata.com/en/stable/get_started/concepts.html" rel="noopener noreferrer"&gt;Citus — Concepts: distributed, reference, and local tables; algorithmic sharding&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.citusdata.com/en/stable/develop/reference_ddl.html" rel="noopener noreferrer"&gt;Citus — Creating and Modifying Distributed Objects (DDL): colocation, foreign-key rules, 2PC on reference tables&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;ClickHouse&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://clickhouse.com/docs/en/engines/table-engines/mergetree-family/mergetree" rel="noopener noreferrer"&gt;ClickHouse — MergeTree table engine (column-oriented storage; sort/primary key)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Amazon Aurora Limitless&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/limitless-reqs-limits.html" rel="noopener noreferrer"&gt;Requirements and considerations — Aurora Global Database, read replicas, and acting as a replication source are all listed under "features not supported"&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/limitless-bak.html" rel="noopener noreferrer"&gt;Backing up and restoring Aurora PostgreSQL Limitless Database&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;MongoDB sharding&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.mongodb.com/docs/manual/sharding/" rel="noopener noreferrer"&gt;Sharding — each shard must be deployed as a replica set; &lt;code&gt;mongos&lt;/code&gt;; config servers&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.mongodb.com/docs/manual/core/sharded-cluster-components/" rel="noopener noreferrer"&gt;Sharded cluster components&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.mongodb.com/docs/manual/core/sharded-cluster-shards/" rel="noopener noreferrer"&gt;Shards — must be deployed as a replica set to provide redundancy and high availability&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Elasticsearch&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.elastic.co/docs/manage-data/data-store/index-basics" rel="noopener noreferrer"&gt;Index fundamentals — primary-shard count is fixed at index creation; replica count can be changed any time and replicas serve reads&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>postgres</category>
      <category>database</category>
      <category>architecture</category>
      <category>elasticsearch</category>
    </item>
    <item>
      <title>You Can Outsource the Work, Not the Ownership</title>
      <dc:creator>Pranay Ravi</dc:creator>
      <pubDate>Fri, 20 Nov 2026 04:59:17 +0000</pubDate>
      <link>https://dev.to/pranay_raavi/you-can-outsource-the-work-not-the-ownership-4hef</link>
      <guid>https://dev.to/pranay_raavi/you-can-outsource-the-work-not-the-ownership-4hef</guid>
      <description>&lt;p&gt;&lt;em&gt;Lessons from years of turning vendor engagements into long-term wins&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Recently, a colleague messaged me to say a project wasn't going well. We had brought in an outside consultant to build our disaster recovery failover plan, and the consultant didn't have the domain knowledge for our systems. The work was drifting.&lt;/p&gt;

&lt;p&gt;My colleague's instinct was right. Instead of asking someone else to write our plans, we should have focused on learning the recovery service ourselves.&lt;/p&gt;

&lt;p&gt;My reply was simple: never leave it to the vendor. My most successful engagements worked because I learned the platform as if I were going to run it myself, and someone on our side took full ownership. Without that, you get exactly what we were looking at.&lt;/p&gt;

&lt;p&gt;That exchange is why I'm writing this post. Most vendor engagements don't fail because the vendor is bad. They fail because the organization hands over the problem and walks away.&lt;/p&gt;

&lt;p&gt;Companies bring in vendors and contractors because they lack a skill. That part is reasonable. The trouble starts when the engagement is treated as insurance: if it goes wrong, it was the vendor's fault. That mindset is the root of most failures I have seen.&lt;/p&gt;

&lt;p&gt;I'm a database and infrastructure engineer. Over the years I've led engagements with Oracle, Splunk, AppDynamics, AWS, and a managed database support provider. Every one of them paid off, some in seven-figure savings and some in ways most organizations never measure: faster incident resolution, reusable know-how, and teams that could stand on their own once the vendor left.&lt;/p&gt;

&lt;p&gt;This post covers what made those engagements work, the stories behind them, and the mistakes I'd tell anyone to avoid.&lt;/p&gt;

&lt;h2&gt;
  
  
  Think like a homeowner hiring a contractor
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7aksrjx8oafb0yc7y0zb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7aksrjx8oafb0yc7y0zb.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you hired a contractor to finish your basement, build a deck, or redo your kitchen, you wouldn't just sign and disappear. You'd learn what needs to be there, short of building it yourself.&lt;/p&gt;

&lt;p&gt;That knowledge lets you challenge the contractor, ask questions they have to answer, and track real progress. It keeps you from overpaying, from getting cheaper parts than you paid for, and from paying for parts the project never needed.&lt;/p&gt;

&lt;p&gt;I apply the same philosophy to every vendor engagement. I may be completely new to the technology on day one. But to make the project succeed, I have to learn it well enough to support it myself. The question I keep asking from start to finish is simple: &lt;strong&gt;how will my organization run this when the vendor is gone?&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Story 1: Oracle GoldenGate — when the vendor becomes your teacher
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3fx9nscb27aqhpv1mqdx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3fx9nscb27aqhpv1mqdx.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I've run GoldenGate projects since my time at Verizon. One of the most valuable engagements of my career was working directly with Oracle to build bidirectional GoldenGate replication.&lt;/p&gt;

&lt;p&gt;Bidirectional replication is unforgiving. Conflict handling, loop prevention, and trail management all have to be right, or data drifts quietly until someone notices. I didn't treat Oracle's engineers as people doing the work for me. I treated them as teachers, and I asked questions until I understood why every setting was there.&lt;/p&gt;

&lt;p&gt;That knowledge became the real deliverable. It carried my career forward, and over the following years it saved the company seven figures, because we could design, run, and troubleshoot replication ourselves instead of paying for outside help each time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lesson:&lt;/strong&gt; build learning into the engagement. The license or the statement of work ends; what your team learned keeps paying.&lt;/p&gt;

&lt;h2&gt;
  
  
  Story 2: Splunk — make the vendor prove your worst log
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnhzbw1y9epzm98hs7hjp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnhzbw1y9epzm98hs7hjp.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Vendor presentations are usually polished, and mostly accurate. But they show the clean cases. Every organization grows its own edge cases over the years, and a demo never covers those.&lt;/p&gt;

&lt;p&gt;In Splunk, sourcetypes are where the parsing logic lives: how a raw log line is broken into fields you can search, alert on, and graph. During the proof of concept, I didn't ask Splunk to parse a clean, well-formatted log. I picked the worst log in the company, the one nobody wanted to touch, and asked them to prove the platform could handle it.&lt;/p&gt;

&lt;p&gt;Their engineers wrote the sourcetype configuration to parse it during the POC. I studied how they built it, reverse-engineered the approach, and reused it to onboard logs for several other projects afterward.&lt;/p&gt;

&lt;p&gt;That work could easily have turned into a paid professional services engagement. It didn't, because I learned how the code worked while the vendor's experts were in the room.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lesson:&lt;/strong&gt; design the POC around your hardest case, not the vendor's easiest one. Then learn from how they solve it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Story 3: AppDynamics — let your internal customers certify the POC
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmt5dx1r5h2vg0yi0qo2y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmt5dx1r5h2vg0yi0qo2y.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With AppDynamics, I leaned on the vendor's know-how to write custom extensions that monitored what the product didn't cover out of the box. Getting close to their architects mattered here. That relationship is what makes or breaks an engagement like this.&lt;/p&gt;

&lt;p&gt;But the bigger lesson was about adoption. The product teams were part of the decision and the POC from the start. They weren't handed a tool someone else had picked. They tested it on their own applications and APIs, and they liked what they saw.&lt;/p&gt;

&lt;p&gt;So the rollout was fast. Teams adopted it without being pushed, and started thinking about how to use it in their own development cycles. The same approach worked for our Splunk rollout.&lt;/p&gt;

&lt;p&gt;The payoff showed up during incidents. Problems that used to take hours of cross-team digging got resolved in a fraction of the time, often by Tier 1 support engineers who could now see API and database performance issues themselves.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lesson:&lt;/strong&gt; if one team certifies a POC and pushes the result onto everyone else, you won't get adoption. Make your internal customers partners in the evaluation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Story 4: AWS — learn how the provider's experts think
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fujeoqzrupppup3dg3k30.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fujeoqzrupppup3dg3k30.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A cloud provider is a different kind of vendor. You aren't buying a project; you're buying services, and the expertise behind them is easy to leave on the table if all you do is open support tickets.&lt;/p&gt;

&lt;p&gt;When we worked with AWS on Database Migration Service (DMS) and AWS Backup, I treated their specialists as a source of knowledge, not just a help desk. I wanted to understand how they think about these services: where they fit, where they don't, and what trips up other customers at scale.&lt;/p&gt;

&lt;p&gt;That understanding shaped how we designed migrations and backup strategy, instead of us discovering the limits the hard way in production.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lesson:&lt;/strong&gt; your cloud provider's architects have seen thousands of customers. Ask them what goes wrong, not just how to configure things.&lt;/p&gt;

&lt;h2&gt;
  
  
  Story 5: A managed DBA team — set the rules early, let them evolve
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fu6isdlfn8uo8ntdzz7ht.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fu6isdlfn8uo8ntdzz7ht.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Sometimes you bring in a vendor because your internal bench is thin. We partnered with a managed database support provider whose DBA team covered work we didn't have the internal depth to handle alone.&lt;/p&gt;

&lt;p&gt;At the start, I set up the procedures and rules of engagement: how work comes in, how it's escalated, who owns what, and what "done" means. It wasn't glamorous work.&lt;/p&gt;

&lt;p&gt;But that foundation held. The support ran seamlessly for years. The rules evolved as both sides gained experience, but we never had to tear them down and start over.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lesson:&lt;/strong&gt; with a managed service, the first few weeks of process design decide how the next several years go.&lt;/p&gt;

&lt;h2&gt;
  
  
  The playbook: what to do
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Write requirements and expectations down up front.&lt;/strong&gt; Vague goals give the vendor room to declare victory on their terms.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ask internal customers what success looks like to them.&lt;/strong&gt; They become your partners in the result, not critics of it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Make the vendor prove it on your platform.&lt;/strong&gt; A thorough POC on your complex scenarios is worth more than any slide deck.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Get close to the vendor's architect.&lt;/strong&gt; That relationship decides whether hard problems get solved or escalated forever.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Learn what you'll be supporting.&lt;/strong&gt; Even if the technology is new to you, learn it well enough to run it alone.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Build learning into the engagement.&lt;/strong&gt; Knowledge transfer is a deliverable, not a favor.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use AI for research.&lt;/strong&gt; Before the engagement, research what success metrics other organizations use for the same kind of platform. It sharpens your requirements and your questions.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;And remember: the vendor wants your project to succeed too. A failed engagement doesn't help their reference list.&lt;/p&gt;

&lt;h2&gt;
  
  
  What not to do
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Don't trust the vendor to do the whole job.&lt;/strong&gt; That's the most reliable recipe for failure I know. Work with them closely, every step.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Don't treat the engagement as cover.&lt;/strong&gt; "We hired experts, so it's on them" protects no one when the system breaks after the vendor leaves.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Don't let one team certify the tool for everyone.&lt;/strong&gt; Adoption you force rarely becomes adoption you keep.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Don't skip the hard cases in the POC.&lt;/strong&gt; If the vendor never touched your messiest system, you haven't tested anything.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Don't buy what you can't support.&lt;/strong&gt; If no one internally can run the product, you'll pay for it for years and get little back.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Don't let internal friction go unaddressed.&lt;/strong&gt; Some engineers would rather build it themselves and see the vendor as a competitor. They focus on why the vendor is failing instead of sharing the context that would make the solution better.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  A note for leaders
&lt;/h2&gt;

&lt;p&gt;The engineer running a vendor engagement carries a lot. These projects are usually meant to solve a real problem or prepare the organization for the future, and that responsibility sits on their shoulders.&lt;/p&gt;

&lt;p&gt;Three things help them succeed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Give them time.&lt;/strong&gt; Don't assume the vendor is doing the work and the internal owner needs only a few hours a week. If you want the project done right, budget real time for it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Set expectations with the team.&lt;/strong&gt; Make it clear why the vendor is there and what the internal owner is accountable for. Clear up concerns early, before they turn into resistance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Give credit where it's earned.&lt;/strong&gt; It's common for people to assume "the vendor did it" and overlook the internal engineer who made it work. Recognize the people who make these partnerships succeed.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How to measure success
&lt;/h2&gt;

&lt;p&gt;Some wins show up on a budget line, like the seven-figure savings from owning GoldenGate in-house. Many don't, and organizations often have no KPI for them.&lt;/p&gt;

&lt;p&gt;The measure I care most about is this: &lt;strong&gt;does the platform enable other people?&lt;/strong&gt; When a Tier 1 support engineer can resolve an API or database performance issue in a fraction of the time it used to take, without escalating, the engagement worked. When teams adopt a tool into their development cycles on their own, it worked. When your team can run the platform after the vendor has gone, it worked.&lt;/p&gt;

&lt;p&gt;Leaders should look for these outcomes and recognize the people who deliver them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Closing thought
&lt;/h2&gt;

&lt;p&gt;Vendor engagements aren't the most exciting work for strong engineers. There's process to design, requirements to chase, and a lot of time spent learning someone else's product.&lt;/p&gt;

&lt;p&gt;But this is foundation work. Done well, it shapes how an organization operates for years. Bring the vendor in for their expertise, and keep the ownership for yourself.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;If you've led vendor engagements of your own, I'd like to hear what worked and what didn't. Share your experience in the comments.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F68xkikofbej3gblzxw5n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F68xkikofbej3gblzxw5n.png" alt=" " width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>career</category>
      <category>devops</category>
      <category>leadership</category>
      <category>database</category>
    </item>
    <item>
      <title>We Don't Do Functional Indexes. Here's Why We Made One Anyway.</title>
      <dc:creator>Pranay Ravi</dc:creator>
      <pubDate>Sat, 14 Nov 2026 23:44:19 +0000</pubDate>
      <link>https://dev.to/pranay_raavi/we-dont-do-functional-indexes-heres-why-we-made-one-anyway-2aip</link>
      <guid>https://dev.to/pranay_raavi/we-dont-do-functional-indexes-heres-why-we-made-one-anyway-2aip</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;We avoid functional indexes and refuse to add an index for every slow query. A vendor-generated Keycloak query took &lt;strong&gt;1.1 s and 2.27 million buffer hits to return zero rows&lt;/strong&gt;. After checking every cheaper option, we added one &lt;code&gt;(name, lower(value))&lt;/code&gt; index. Result: &lt;strong&gt;0.2 ms and 11 buffers.&lt;/strong&gt; Below is why the rule exists, why we broke it, and the checklist we now use for exceptions.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  The rules
&lt;/h2&gt;

&lt;p&gt;Below are a couple of rules we rarely break:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;No function-based (expression) indexes.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No new index for every slow query.&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Last week we broke both, on purpose, for one index on a table we don't own.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbtphvai2kadnknkrvlod.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbtphvai2kadnknkrvlod.png" alt="A stack of index cards burying a single database table" width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why we have them
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Every index has a cost on every write&lt;/strong&gt;, not only on the read it was built for. Each &lt;code&gt;INSERT&lt;/code&gt; and each &lt;code&gt;UPDATE&lt;/code&gt; to an indexed column means another B-tree insertion, more WAL, more vacuum work and more storage. One index is cheap. Thirty indexes on a busy table are not, and that's where you end up if every slow query gets its own index.&lt;/p&gt;

&lt;p&gt;Functional indexes add their own problems:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;They only match an identical expression.&lt;/strong&gt; An index on &lt;code&gt;lower(value)&lt;/code&gt; does nothing for &lt;code&gt;upper(value)&lt;/code&gt;, &lt;code&gt;value ILIKE ...&lt;/code&gt;, or &lt;code&gt;lower(trim(value))&lt;/code&gt;. One small change to the query and the index silently stops being used, but you keep paying for it on every write.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;They hide the real problem.&lt;/strong&gt; If code wraps a column in a function, the usual fix is to normalize the data or change the query.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;On vendor schemas they cause upgrade problems.&lt;/strong&gt; If the application manages its own schema (Liquibase, Flyway), your extra index can conflict with the vendor's next migration.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So when a developer asked for this, my first answer was no:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;INDEX&lt;/span&gt; &lt;span class="no"&gt;CONCURRENTLY&lt;/span&gt; &lt;span class="n"&gt;idx_user_attrs_name_lower_value&lt;/span&gt;
    &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;user_attributes&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;My exact words were roughly: &lt;em&gt;"Using &lt;code&gt;lower()&lt;/code&gt; is not a good query. Wrapping the column in lower() on the left side of the WHERE clause bypasses the index on value. That's a query problem, not an indexing problem. Is there a reason to think the stored values aren't already lowercase? If they are, drop the lower(). We avoid functional indexes."&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The query
&lt;/h2&gt;

&lt;p&gt;The table is Keycloak's user-attribute table. I've simplified the table, index and column names here, but the shape is the real one. The query searches for a user by a custom attribute:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;DISTINCT&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;
&lt;span class="k"&gt;LEFT&lt;/span&gt; &lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;user_attributes&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;user_id&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="nb"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tenant_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt;
&lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;username&lt;/span&gt; &lt;span class="k"&gt;OFFSET&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="k"&gt;ROWS&lt;/span&gt; &lt;span class="k"&gt;FETCH&lt;/span&gt; &lt;span class="k"&gt;FIRST&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="k"&gt;ROWS&lt;/span&gt; &lt;span class="k"&gt;ONLY&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The only existing index on these columns is &lt;code&gt;(name, value)&lt;/code&gt;, which can't serve &lt;code&gt;lower(value) = ?&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The developer's answer to my question: &lt;strong&gt;we don't write this query. Keycloak does.&lt;/strong&gt; The Admin REST API's "exact" attribute search is case-insensitive by design, so Keycloak's JPA layer wraps the column in &lt;code&gt;lower()&lt;/code&gt;. No API flag turns that off. Normalizing the data to lowercase doesn't help either, because the predicate still has &lt;code&gt;lower()&lt;/code&gt; around the column.&lt;/p&gt;

&lt;p&gt;That ruled out the usual fix of changing the query. Sometimes if the design permits, we also create an additional lowercase column while preserving the input value in the original column.&lt;/p&gt;

&lt;h2&gt;
  
  
  My first test proved nothing
&lt;/h2&gt;

&lt;p&gt;I ran &lt;code&gt;EXPLAIN ANALYZE&lt;/code&gt; with an attribute I picked at random:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Bitmap Index Scan on idx_user_attrs_name_value  (actual rows=11)
Execution Time: 0.112 ms
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That looked fine. But the attribute I picked had &lt;strong&gt;11 rows&lt;/strong&gt; in the table. The attribute that actually caused problems in our user migration had about &lt;strong&gt;388,000&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The worst case
&lt;/h2&gt;

&lt;p&gt;Same query, the high-volume attribute, and a value that doesn't exist (the normal case during migration, where most lookups miss):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Limit  (cost=1230.03..10786.46 rows=100) (actual time=1124.919..1127.088 rows=0)
  Buffers: shared hit=2268828
  -&amp;gt;  Unique  (rows=1936)
        -&amp;gt;  Nested Loop
              -&amp;gt;  Parallel Index Scan on users (username order)
                    (actual rows=131677 loops=3)
              -&amp;gt;  Index Scan using idx_user_attrs_user_id on user_attributes
                    (actual rows=0 loops=395031)
                    Filter: name = '...' AND lower(value) = '...'
                    Rows Removed by Filter: 4
Execution Time: 1127.156 ms
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's &lt;strong&gt;1.1 seconds and 2.27 million buffer hits (about 17 GB of page reads) to return zero rows.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
  Full EXPLAIN (ANALYZE, BUFFERS) output: before
  &lt;br&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Limit  (cost=1230.03..10786.46 rows=100 width=739) (actual time=1124.919..1127.088 rows=0 loops=1)
  Buffers: shared hit=2268828
  -&amp;gt;  Unique  (cost=1230.03..186242.65 rows=1936 width=739) (actual time=1124.917..1127.087 rows=0 loops=1)
        -&amp;gt;  Gather Merge  (cost=1230.03..186179.73 rows=1936 width=739)
              Workers Planned: 2
              Workers Launched: 2
              -&amp;gt;  Incremental Sort  (cost=230.00..184956.25 rows=807 width=739)
                    Sort Key: u.username, u.id, ...
                    Presorted Key: u.username
                    -&amp;gt;  Nested Loop  (cost=0.85..184919.93 rows=807 width=739)
                          Buffers: shared hit=2268672
                          -&amp;gt;  Parallel Index Scan using uq_users_tenant_username on users u
                                (actual time=0.029..135.635 rows=131677 loops=3)
                                Index Cond: (tenant_id = '&amp;lt;tenant-id&amp;gt;')
                                Buffers: shared hit=398390
                          -&amp;gt;  Index Scan using idx_user_attrs_user_id on user_attributes a
                                (actual time=0.007..0.007 rows=0 loops=395031)
                                Index Cond: (user_id = u.id)
                                Filter: ((name = '...') AND (lower(value) = '...'))
                                Rows Removed by Filter: 4
                                Buffers: shared hit=1870282
Planning Time: 0.360 ms
Execution Time: 1127.156 ms
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fw4fkmaz7ik3qjswp0zxt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fw4fkmaz7ik3qjswp0zxt.png" alt="Planner walking past hundreds of thousands of doors checking each one" width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Why the planner chose this plan
&lt;/h3&gt;

&lt;p&gt;Look at &lt;code&gt;rows=1936&lt;/code&gt;. That's 388,271 × 0.005. With no statistics on &lt;code&gt;lower(value)&lt;/code&gt;, PostgreSQL falls back to its default equality selectivity of &lt;strong&gt;0.5%&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;So the planner thought: &lt;em&gt;"About 1,936 users match. I need the first 100 in username order. I'll walk users in username order and stop after about 5% of the tenant's users."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;You can check this against the cost numbers: &lt;code&gt;1230 + (186242 − 1230) × 100 / 1936 ≈ 10786&lt;/code&gt;, which is exactly the &lt;code&gt;Limit&lt;/code&gt; cost.&lt;/p&gt;

&lt;p&gt;That's a sensible plan if the estimate is right. When the value doesn't exist, the walk never stops early. It reads all ~395,000 users and probes their attributes one by one. When a lookup does hit, it still reads on average half the tenant's users.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fn9drc6a5c1p1rypri9ul.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fn9drc6a5c1p1rypri9ul.png" alt="A planner confidently guessing 1,936 matches while the real answer is zero" width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A few details mattered:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;This happened with literal values.&lt;/strong&gt; It wasn't only a generic-plan problem with prepared statements. The custom plan was just as bad.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;OFFSET&lt;/code&gt; made no difference.&lt;/strong&gt; &lt;code&gt;OFFSET 0&lt;/code&gt; and &lt;code&gt;OFFSET 100&lt;/code&gt; gave the same plan and the same cost.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It scales with the table.&lt;/strong&gt; As the attribute grows, the default guess grows too, so the planner gets more confident in the wrong plan.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Buffers show where the work went.&lt;/strong&gt; About 82% of the 2.27M buffers came from probing attributes for users that never matched.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At 1.1 s on an idle database with 2 parallel workers per query, a burst of concurrent misses during migration pushed lookups to &lt;strong&gt;9–53 seconds&lt;/strong&gt;. Clients timed out and retried, and the abandoned queries kept running.&lt;/p&gt;

&lt;h2&gt;
  
  
  Every alternative we tried first
&lt;/h2&gt;

&lt;p&gt;We went through the cheaper options before accepting an index:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Option&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;plan_cache_mode = force_custom_plan&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Doesn't help. The custom plan with literals is already the bad plan.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;CREATE STATISTICS ... ON (lower(value))&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Fixes the estimate without an index, but then scans all 388k entries for that attribute. Better, still slow.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Partial index &lt;code&gt;WHERE name = '...'&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Keycloak passes &lt;code&gt;name&lt;/code&gt; as a bind parameter, so a generic plan can't use it.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;citext&lt;/code&gt; / case-insensitive collation&lt;/td&gt;
&lt;td&gt;The query still wraps the column in &lt;code&gt;lower()&lt;/code&gt;, so no index matches. It also changes a vendor-owned column.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Replace &lt;code&gt;(name, value)&lt;/code&gt; with &lt;code&gt;(name, lower(value))&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Breaks Keycloak's case-sensitive exact-match path, and drops a vendor-managed index.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Nothing short of the index turned this into a point lookup.&lt;/p&gt;

&lt;h2&gt;
  
  
  After
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;INDEX&lt;/span&gt; &lt;span class="no"&gt;CONCURRENTLY&lt;/span&gt; &lt;span class="n"&gt;idx_user_attrs_name_lower_value&lt;/span&gt;
    &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;user_attributes&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;ANALYZE&lt;/span&gt; &lt;span class="n"&gt;user_attributes&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Nested Loop  (actual rows=0)
  -&amp;gt;  Index Scan using idx_user_attrs_name_lower_value on user_attributes
        Index Cond: (name = '...' AND lower(value) = '...')
        Buffers: shared hit=3
  -&amp;gt;  Index Scan using users_pkey on users  (never executed)
Execution Time: 0.218 ms
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/IMAGE_URL_BEFORE_AFTER" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/IMAGE_URL_BEFORE_AFTER" alt="Before vs after: a long walk through every user vs a single index lookup" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Before&lt;/th&gt;
&lt;th&gt;After&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Execution time&lt;/td&gt;
&lt;td&gt;1,127 ms&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.218 ms&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Buffers&lt;/td&gt;
&lt;td&gt;2,268,828&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;11&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Row estimate&lt;/td&gt;
&lt;td&gt;1,936 (guess)&lt;/td&gt;
&lt;td&gt;6 (real statistics)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The index gives two things: &lt;strong&gt;an access path&lt;/strong&gt; and &lt;strong&gt;statistics&lt;/strong&gt;. &lt;code&gt;ANALYZE&lt;/code&gt; collects statistics on indexed expressions, so the planner stopped guessing and started from the attribute side by itself.&lt;/p&gt;

&lt;p&gt;We also found that the Keycloak maintainers have been working on the same thing: &lt;a href="https://github.com/keycloak/keycloak/pull/54578" rel="noopener noreferrer"&gt;an open upstream PR&lt;/a&gt; adds this exact &lt;code&gt;(name, lower(value))&lt;/code&gt; index to Keycloak's schema. We weren't adding something odd. We were filling a gap in the vendor schema that upstream is already closing.&lt;/p&gt;

&lt;h2&gt;
  
  
  The exception checklist
&lt;/h2&gt;

&lt;p&gt;The rules stay. A functional index now has to pass &lt;strong&gt;all&lt;/strong&gt; of these:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The SQL can't be changed.&lt;/strong&gt; It's vendor or ORM generated, and no config or upstream fix is available on our version.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It's a hot path,&lt;/strong&gt; with a stated call rate and latency requirement.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;There's evidence of a real problem.&lt;/strong&gt; &lt;code&gt;EXPLAIN (ANALYZE, BUFFERS)&lt;/code&gt; on the &lt;em&gt;worst case&lt;/em&gt; (high-volume values, misses, generic plans), not a convenient example.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cheaper fixes were tried and measured:&lt;/strong&gt; statistics, plan settings, query or data changes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It's documented and reviewed:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="no"&gt;COMMENT&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="k"&gt;INDEX&lt;/span&gt; &lt;span class="n"&gt;idx_user_attrs_name_lower_value&lt;/span&gt; &lt;span class="k"&gt;IS&lt;/span&gt;
  &lt;span class="s1"&gt;'Exception: vendor SQL uses lower(value) | owner: DBA | review at next Keycloak major upgrade'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What I'd tell my past self
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Test the worst case, not the first example that comes to mind.&lt;/strong&gt; My 0.1 ms test was real, but it only covered the easy case.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Read buffers, not just timing.&lt;/strong&gt; Going from 2.27M buffers to 11 is evidence that holds whether the server is busy or idle.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Treat rules as defaults.&lt;/strong&gt; "No functional indexes" protected us from dozens of bad indexes. Making this one exception, with evidence and a review date, keeps the rule credible.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;How does your team decide when an index is worth its write cost? I'd like to hear your rules in the comments.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F93nwz5lykgwoc8xaqmsq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F93nwz5lykgwoc8xaqmsq.png" alt=" " width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>postgres</category>
      <category>database</category>
      <category>performance</category>
      <category>keycloak</category>
    </item>
    <item>
      <title>Cloud Migration: 9 Real-World Things to Keep in Mind</title>
      <dc:creator>Pranay Ravi</dc:creator>
      <pubDate>Thu, 12 Nov 2026 07:09:07 +0000</pubDate>
      <link>https://dev.to/pranay_raavi/what-to-keep-in-mind-for-a-cloud-migration-56mg</link>
      <guid>https://dev.to/pranay_raavi/what-to-keep-in-mind-for-a-cloud-migration-56mg</guid>
      <description>&lt;p&gt;I have led a couple of platform migrations, from on-premises to AWS and from one AWS account structure to another. Each time my job was to coordinate the application, database, DevOps and network teams from scoping to cutover.&lt;/p&gt;

&lt;p&gt;This is the list I would want you to keep in mind before you start one. It is grouped into seven categories. Under each I say what to think about and, where it helps, what we did.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Scope: decide what changes and what waits
&lt;/h2&gt;

&lt;p&gt;A migration is a chance to modernize, and it is also the easiest place to over-engineer. Start from the rules of the target environment. Ours were no static credentials, TLS on database connections, nothing public by default, autoscaling, and tags on every resource so cost splits by application.&lt;/p&gt;

&lt;p&gt;Then list every improvement someone wants and make a call on each one.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Area&lt;/th&gt;
&lt;th&gt;Think about&lt;/th&gt;
&lt;th&gt;What we did&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Database&lt;/td&gt;
&lt;td&gt;Move to a managed engine? Upgrade the major version in the same move?&lt;/td&gt;
&lt;td&gt;Moved to Aurora with an engine upgrade and TLS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Runtime&lt;/td&gt;
&lt;td&gt;Can VMs, ECS and EKS collapse into one?&lt;/td&gt;
&lt;td&gt;Consolidated on EKS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Secrets&lt;/td&gt;
&lt;td&gt;Use a secrets manager and take passwords out of code and config files&lt;/td&gt;
&lt;td&gt;Secrets moved into AWS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Configuration&lt;/td&gt;
&lt;td&gt;Externalize parameters so the same build deploys to every environment&lt;/td&gt;
&lt;td&gt;Config maps&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Logging&lt;/td&gt;
&lt;td&gt;Send application logs to a central store instead of local disk&lt;/td&gt;
&lt;td&gt;Central search cluster&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Access&lt;/td&gt;
&lt;td&gt;Use roles between services and drop long-lived keys&lt;/td&gt;
&lt;td&gt;Role-based access&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pipeline&lt;/td&gt;
&lt;td&gt;Can one pipeline deploy everything? Is GitOps in reach?&lt;/td&gt;
&lt;td&gt;One CI server in a shared account. GitOps came later, once the runtime was standard&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Search and loaders&lt;/td&gt;
&lt;td&gt;Upgrade or rewrite now, or carry them over as they are?&lt;/td&gt;
&lt;td&gt;Deferred. Both needed application code changes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Backups&lt;/td&gt;
&lt;td&gt;Does going live need a new backup design?&lt;/td&gt;
&lt;td&gt;Deferred. Snapshots were enough&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two columns in the task tracker kept this honest: "key project goal" and "blocker for the first environment". A task with a no in both waited.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Discovery: get the complete picture
&lt;/h2&gt;

&lt;p&gt;Get a complete application architecture diagram before anyone builds. Expect the first version to be partial, and keep asking. A platform that has run for years has connections nobody wrote down.&lt;/p&gt;

&lt;p&gt;Build an inventory for every environment:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Which component runs where, and why it runs there.&lt;/li&gt;
&lt;li&gt;Every DNS name, with its zone, load balancer, protocol, target group and the resource behind it.&lt;/li&gt;
&lt;li&gt;Every inbound caller and every outbound dependency.&lt;/li&gt;
&lt;li&gt;Every loader, job and script that reads or writes the data.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Check your assumptions two and three times, including the convenient ones. We worried that bucket names were stored in the database, which would have made renaming buckets painful. We checked, and they were in a properties file. We also assumed a transit gateway would cover traffic between accounts, and we needed VPC peering as well.&lt;/p&gt;

&lt;p&gt;Compare the environments against each other. Production and non-production are rarely built the same way, and the differences are where the cutover steps change.&lt;/p&gt;

&lt;p&gt;Even with all of this, three things found us late: another product's web client that read our object storage directly, a data warehouse job that read a logging table we planned to retire, and a monitoring script that counted documents in the old search cluster. Leave room in the plan for your own version of these.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. People and calendar: one scrum, one plan
&lt;/h2&gt;

&lt;p&gt;Each team has its own backlog, its own way of working and other projects competing for the same people. Someone has to keep those plans moving as one.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Run one scrum across all teams.&lt;/strong&gt; Ours started weekly, went to twice a week to clear blockers, and became daily near the first cutover.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ask every team the same three questions.&lt;/strong&gt; What are you working on, and what is the estimate? What is blocked or likely to slip, and what is the alternative? What still has to happen for the next environment to cut over on its date?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep one board.&lt;/strong&gt; One epic, with each team's own tickets linked in.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Spell out requirements early.&lt;/strong&gt; When one team settles on a solution, share what it needs from the others the same day.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Post outcomes in the shared channel.&lt;/strong&gt; Two-person working sessions are fine, but the result belongs where every team sees it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Follow up instead of waiting.&lt;/strong&gt; It never hurts to over-communicate.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Plan around the calendar.&lt;/strong&gt; Change freezes, public holidays and time off for key people all punch holes in a quarter. Keep a tab for who is out and when, and set each environment window around it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Dates will still move, and ours did on the first environment. Build slack around the known gaps so one slip does not push every later window.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Data: the part that decides the cutover
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0o8qshp8sg6rzhm6mjh7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0o8qshp8sg6rzhm6mjh7.png" alt=" " width="800" height="339"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Compute can be redeployed. Data has to be moved, kept in sync and proven correct, so it shapes the whole cutover. There is no single right method, only questions you have to answer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can you take downtime?&lt;/strong&gt; Decide this first, with the product owner. A short window removes a whole class of design. We could take one.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;One direction or two?&lt;/strong&gt; Bidirectional replication buys an easy rollback and costs you conflict handling and weeks of testing. We tested replicating back from the upgraded engine to the old one and hit problems. We chose one direction: seed the new database from a shared snapshot, replicate old to new with native replication, and roll back by export and import. That rollback carries downtime, so tell the product team before they agree.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Native or heterogeneous tooling?&lt;/strong&gt; Every engine has its own replication. Tools such as AWS DMS or Oracle GoldenGate cover moves across engines. Pick the option with the fewest steps to script and test. For us that was native.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Where else does the data live?&lt;/strong&gt; Rarely in one place. Ours was in three, each with its own method:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Store&lt;/th&gt;
&lt;th&gt;How it moved&lt;/th&gt;
&lt;th&gt;Rollback&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Relational database&lt;/td&gt;
&lt;td&gt;Snapshot seed, then one-way native replication&lt;/td&gt;
&lt;td&gt;Export and import&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Search cluster&lt;/td&gt;
&lt;td&gt;Snapshot to a shared bucket and restore, then a remote reindex of the current day during the window&lt;/td&gt;
&lt;td&gt;Reindex back&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Object storage&lt;/td&gt;
&lt;td&gt;Bidirectional bucket replication, left on for days after cutover&lt;/td&gt;
&lt;td&gt;Files already in both accounts&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;What feeds it and what reads it?&lt;/strong&gt; List every inbound loader and every downstream reader. We stopped the loaders before the window and repointed them after. The downstream warehouse stayed on the old database for one more day.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What can testing break?&lt;/strong&gt; Readiness tests that write to the new database while replication is running can break the replication. Plan which tests write, and when.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Network and edges: where it usually breaks
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fen1ywhhpfgyqf1lfkz4p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fen1ywhhpfgyqf1lfkz4p.png" alt=" " width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The application and the database get the attention. The surprises come from DNS, load balancers and allowlists.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DNS.&lt;/strong&gt; If the domain's hosting moves too, stage it so a rollback never touches the registrar. We moved ours into Route 53 like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create the new hosted zone as an empty shell. Not live, and no records created early.&lt;/li&gt;
&lt;li&gt;Add temporary names in the old zone that point at the new load balancers, so the new stack can be tested before cutover.&lt;/li&gt;
&lt;li&gt;At cutover, repoint the old zone's records to the new load balancers.&lt;/li&gt;
&lt;li&gt;The next day, sync the records into the new zone.&lt;/li&gt;
&lt;li&gt;After 24 hours, publish the new name servers at the registrar next to the old ones.&lt;/li&gt;
&lt;li&gt;After another 24 hours, remove the old name servers and watch the URL monitors.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Load balancers.&lt;/strong&gt; Decide where TLS terminates, what the listener rules are, and whether each endpoint gets its own load balancer or shares one with host and path routing. Have services call each other through a load balancer or a DNS name, not through the cluster's internal networking.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Allowlists.&lt;/strong&gt; A new account means new outbound addresses. Every partner and internal service that allowlisted the old ones needs the new ones before cutover. Give every outbound call (email delivery, analytics, partner APIs) its own line in the inventory. Check inbound routes too, such as loaders that still run on-premises.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Object storage.&lt;/strong&gt; If browser or mobile clients read buckets directly, the CORS rules move with the buckets. If bucket names change, find every place a name is stored.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Edge protection.&lt;/strong&gt; Check what sits in front of production that the lower environments lack. One of our APIs was behind a web application firewall only in production, and a deployment that rewrote its DNS record would have broken it.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Cutover: rehearse it the same way every time
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F8q8chmy2u2752hfq4cko.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F8q8chmy2u2752hfq4cko.png" alt=" " width="800" height="339"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Cut over the lowest environment exactly the way you will cut over production. People will ask why QA needs this much ceremony. QA is the only rehearsal production gets.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Use one runbook format for every environment.&lt;/strong&gt; Ours had a preparation tab, a cutover tab, a rollback tab and a DNS tab. Every row had a date, time, duration, team, owner and status.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Write the application test cases before the first environment.&lt;/strong&gt; Run the same set in every environment.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Get a sign-off from each team.&lt;/strong&gt; Once before the window and again after it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Script every cutover and rollback command.&lt;/strong&gt; Store the scripts before the night.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Say ahead of time what a lower environment cannot prove.&lt;/strong&gt; A production-only firewall, a registrar change and a disaster-recovery copy are typical.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Give cleanup its own change request.&lt;/strong&gt; We had two people present for every bucket deletion.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Our rehearsals showed that deployments had to finish before the window, that published DNS had to be checked against expected results, and that the cutover needed an application redeploy. Each of those would have been a surprise in production.&lt;/p&gt;

&lt;p&gt;For a sense of scale, our production runbook budgeted about forty minutes from cutting traffic to sign-off.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Monitoring, retention and cost: decide early
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Monitoring.&lt;/strong&gt; Set up monitoring and central logging in the new environment before the cutover. Put full coverage of databases and application URLs on the production readiness list. Stay on one approved logging path. If the cluster auto-instruments applications, a new service comes up already covered.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Retention.&lt;/strong&gt; Autoscaling without retention is a bill that grows quietly. Set retention at every layer as it is built: log indices, database logging tables, buckets and container images. We left some of these until after cutover, and I would not do that again.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cost.&lt;/strong&gt; The cost lessons are mostly about deciding early:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pick instance classes before the build, so reserved capacity can be planned.&lt;/li&gt;
&lt;li&gt;Run the consolidated cluster on reserved instances.&lt;/li&gt;
&lt;li&gt;Create temporary instances with volumes that delete on termination.&lt;/li&gt;
&lt;li&gt;Question any design that copies data between accounts more than it needs to.&lt;/li&gt;
&lt;li&gt;Ask whether every log line is needed before paying to ship and store it.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  8. Compliance: build it to pass the audit
&lt;/h2&gt;

&lt;p&gt;If the platform falls under HIPAA, SOC 2 or another framework, find out before the design starts. The framework decides encryption, access, logging and retention. Building those in costs far less than retrofitting them before an audit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Which services are allowed?&lt;/strong&gt; In a regulated environment, confirm that every service in the design is covered by your agreement with the cloud provider. For HIPAA on AWS, that means the HIPAA-eligible services under your business associate agreement.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What do the applications write to logs?&lt;/strong&gt; Review this before the logs are shipped anywhere central. Sensitive values should be masked in the application. A migration that centralizes logging also centralizes any leak.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If sensitive data does reach the logs, are the logs secure?&lt;/strong&gt; Assume it will happen once. For CloudWatch Logs, encrypt the log groups with a KMS key and limit who can read them through IAM. Set a retention period on every group, because the default keeps logs forever. Consider a data protection policy that masks known patterns.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can the architecture produce evidence?&lt;/strong&gt; An auditor asks for proof. Think about what the new environment will show for each control:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Access by role, with no shared or static credentials.&lt;/li&gt;
&lt;li&gt;Encryption in transit and at rest for every data store.&lt;/li&gt;
&lt;li&gt;An audit trail for API activity and for database access.&lt;/li&gt;
&lt;li&gt;Change records for the migration: approvals, sign-offs and the runbook.&lt;/li&gt;
&lt;li&gt;Restore tests for backups.&lt;/li&gt;
&lt;li&gt;No production data in lower environments, or masked data only.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A multi-account structure helps here, because guardrails are set once at the organization level and every new account inherits them. An engine upgrade can help too, when the newer version brings audit features.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. Disaster recovery and backups: design them with the migration
&lt;/h2&gt;

&lt;p&gt;Disaster recovery is easy to leave for later. Start it at scoping, because it changes region, network and cost decisions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are the targets?&lt;/strong&gt; Agree a recovery time and a recovery point for each component with the product owner. Those two numbers pick the pattern: backup and restore, pilot light, warm standby or active-active. Each step up costs more.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What does each layer of the stack support?&lt;/strong&gt; Go through the stack and write down the recovery option for every layer:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Layer&lt;/th&gt;
&lt;th&gt;Options to consider&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Database&lt;/td&gt;
&lt;td&gt;Cross-region replica or global database, or restore from copied snapshots&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Object storage&lt;/td&gt;
&lt;td&gt;Cross-region replication&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Search cluster&lt;/td&gt;
&lt;td&gt;Snapshots copied to the second region, or cross-cluster replication&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Compute&lt;/td&gt;
&lt;td&gt;Images replicated to a registry in the second region, cluster rebuilt by automation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DNS and traffic&lt;/td&gt;
&lt;td&gt;Health checks and failover routing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Secrets and configuration&lt;/td&gt;
&lt;td&gt;Replicated, or re-created by the same automation&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Can the second region hold the same design?&lt;/strong&gt; Check that it offers the same services, the same instance classes and enough availability zones. Plan its subnets and address ranges next to the primary's so they do not overlap. Check service quotas there too.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Are snapshots enough?&lt;/strong&gt; Decide whether platform snapshots meet the requirement, or whether a regulation asks for separate, longer-term copies. Either way, test a restore.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How long is everything kept?&lt;/strong&gt; Design retention for each class of data: backups, snapshots, logs and archives. Tie each period to the requirement behind it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What happens to the legacy data?&lt;/strong&gt; Old on-premises or legacy backups and archives carry retention obligations that outlive the migration. Choose for each one: carry it into the new environment on an archive storage tier, keep the old system read-only until the period ends, or dispose of it with a sign-off. Answer this before the old environment is decommissioned.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Has it been exercised?&lt;/strong&gt; Rehearse a failover the way you rehearse the cutover. Until then it is only a plan.&lt;/p&gt;

&lt;h2&gt;
  
  
  My take
&lt;/h2&gt;

&lt;p&gt;A migration is mostly coverage. Know what you have, decide what changes now and what waits, move the data with a rollback you have tested, and rehearse the cutover in every environment. In my experience the hard moments come from things nobody wrote down far more often than from the technology.&lt;/p&gt;

&lt;p&gt;It is also never one person's work. Application, database, DevOps and network engineers build it. The lead's job is to keep the scope honest, the plan visible and the teams talking to each other.&lt;/p&gt;

&lt;p&gt;With a clear scope, a complete architecture diagram, a regular scrum and a firm timeline, and with AI tools to speed up the inventory and runbook work, three to five months is a fair plan for most platform migrations.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fva3mmaw958ww3tvhlr11.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fva3mmaw958ww3tvhlr11.png" alt=" " width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>cloud</category>
      <category>devops</category>
      <category>database</category>
    </item>
  </channel>
</rss>
