Link Search Menu Expand Document Documentation Menu

Segment replication

With segment replication, segment files are copied across shards instead of documents being indexed on each shard copy. This improves indexing throughput and lowers resource utilization at the expense of increased network utilization.

When the primary shard sends a checkpoint to replica shards on a refresh, a new segment replication event is triggered on replica shards. This happens:

  • When a new replica shard is added to a cluster.
  • When there are segment file changes on a primary shard refresh.
  • During peer recovery, such as replica shard recovery and shard relocation (explicit allocation using the move allocation command or automatic shard rebalancing).

Segment replication is the first feature in a series of features designed to decouple reads and writes in order to lower compute costs.

Use cases

  • Users who have high write loads but do not have high search requirements and are comfortable with longer refresh times.
  • Users with very high loads who want to add new nodes, as you do not need to index all nodes when adding a new node to the cluster.
  • OpenSearch cluster deployments with low replica counts, such as those used for log analytics.

Segment replication configuration

To set segment replication as the replication strategy, create an index with replication.type set to SEGMENT:

PUT /my-index1
  "settings": {
    "index": {
      "replication.type": "SEGMENT" 

In segment replication, the primary shard is usually generating more network traffic than the replicas because it copies segment files to the replicas. Thus, it’s beneficial to distribute primary shards equally between the nodes. To ensure balanced primary shard distribution, set the dynamic cluster.routing.allocation.balance.prefer_primary setting to true. For more information, see Cluster settings.

Comparing replication benchmarks

During initial benchmarks, segment replication users reported 40% higher throughput than when using document replication with the same cluster setup.

The following benchmarks were collected with OpenSearch-benchmark using the stackoverflow and nyc_taxi datasets.

Both test runs were performed on a 10-node (m5.xlarge) cluster with 10 shards and 5 replicas. Each shard was about 3.2GBs in size. The tests were run with the following settings:

  • indices.recovery.max_bytes_per_sec: 10gb
  • indices.recovery.max_concurrent_file_chunks: 5

The benchmarking results are listed in the following table.

Document Replication Segment Replication Percent difference
Test execution time (minutes) 40.00 22.00
Throughput (number of requests per second) p0 17553.90 28584.30 63%
p50 20647.20 32790.20 59%
p100 23209.00 34286.00 48%
CPU (%) p50 65.00 30.00 -54%
p90 79.00 35.00 -56%
p99 98.00 45.08 -54%
p100 98.00 59.00 -40%
Memory (%) p50 48.20 39.00 -19%
p90 62.00 61.00 -2%
p99 66.21 68.00 3%
p100 71.00 69.00 -3%
IOPS p50
Latency p50

Your results may vary based on the cluster topology, hardware used, shard count, and merge settings.

Other considerations

When using segment replication, consider the following:

  1. Enabling segment replication for an existing index requires reindexing.
  2. Rolling upgrades are not currently supported. Full cluster restarts are required when upgrading indexes using segment replication. See Issue 3881.
  3. Cross-cluster replication does not currently use segment replication to copy between clusters.
  4. Increased network congestion on primary shards. See Issue - Optimize network bandwidth on primary shards.
  5. Integration with remote-backed storage as the source of replication is currently unsupported.
  6. Read-after-write guarantees: The wait_until refresh policy is not compatible with segment replication. If you use the wait_until refresh policy while ingesting documents, you’ll get a response only after the primary node has refreshed and made those documents searchable. Replica shards will respond only after having written to their local translog. We are exploring other mechanisms for providing read-after-write guarantees. For more information, see the corresponding GitHub issue.
  7. System indexes will continue to use document replication internally until read-after-write guarantees are available. In this case, document replication does not hinder the overall performance because there are few system indexes.

Next steps

  1. Track future enhancements to segment replication.
  2. Read this blog post about segment replication.

Related articles

350 characters left

Want to contribute? or .