What Is Write Consistency Tuning (wait_for_active_shards) in Elasticsearch?

What Is Write Consistency Tuning (wait_for_active_shards) in Elasticsearch?

A complete, step-by-step guide to deciding how many copies of your data must be ready before Elasticsearch accepts a write: what the setting really does, what it does not do, and how to choose a value that balances safety against availability.

It is five o’clock on a Friday afternoon. A server that belongs to your Elasticsearch cluster reboots for a routine security patch. It holds the backup copy of a busy index that stores customer orders. For the next three minutes, orders keep flowing in, and Elasticsearch happily says “success” to every one of them. Nothing looks wrong. But during those three minutes, every new order exists in exactly one place. If the disk under that single copy failed right then, those orders would be gone, and every “success” message would turn out to have been a promise the system could not keep.

One small setting exists to decide what should happen in that moment: wait_for_active_shards. It tells Elasticsearch how many copies of the data must be alive and ready before it is even willing to start a write. Set it low, and writes keep flowing even when backups are missing. Set it higher, and writes pause or fail until enough copies are ready. This article explains every part of it in plain language: the vocabulary, what happens inside the cluster, what the setting guarantees and what it does not, how to choose a value, and how to watch for trouble.

WWhat Is Write Consistency Tuning?

Start here. By the end of this chapter you will know what a shard copy is, what the setting controls, and why it is often misunderstood.

Elasticsearch splits every index into pieces called shards. To survive the loss of a machine, each shard exists in several copies. One copy is the primary, and the others are replicas. Every write goes first to the primary and is then passed on to the replicas, so that all the copies hold the same data.

Write consistency tuning is the practice of choosing how many of those copies must be active, meaning up and ready, before Elasticsearch begins a write. The setting that does this is called wait_for_active_shards, and this article writes it simply as wait_for_active_shards. You can give it a number, such as 2, or the word “all.” By default the number is 1, which means that only the primary copy has to be active. If you raise it to 2, at least one replica must also be active. If you set it to “all,” every copy that the index is supposed to have must be active.

A precondition, not a promise

The most important thing to understand about this setting is what kind of rule it is. It is a precondition: a check made before the write starts. It says, “I will not begin unless enough copies are ready.” It is not a guarantee that the write reached that many copies by the time it finished. Once a write is underway, a replica can still fail, and the write can still succeed on the copies that remain. Later chapters explain how Elasticsearch handles that case, and why the response to every write tells you how many copies really received it.

Everyday analogy

Think of an airline’s pre-flight checklist. A plane with four engines can fly safely on three, or even two. But a careful airline may have a rule: “Do not take off unless at least three engines are working.” That rule is checked on the runway, before the plane starts to roll. It does not promise that no engine will fail in the air. It only promises that you did not depart in a weakened state. The setting wait_for_active_shards is that runway rule for your writes.

1
the default: only the primary copy must be active
all
the strictest choice: the primary and every replica must be active
Before
the moment the check happens: before the write begins, not after

Where you meet it

You will meet the setting in three places. You can put it on an individual write request, such as indexing a document, sending a bulk request, updating or deleting. You can set it as a default for a whole index, so that every write to that index follows it unless a request says otherwise. And you will meet a related use when you create, open, roll over or resize an index, where the same idea means “do not return until enough shard copies have started.”

A short history

Older versions of Elasticsearch, before the 5.0 release in 2016, had a similar setting named consistency. It accepted the words “one,” “quorum” and “all,” and it was borrowed from the language of distributed databases. Over time the Elasticsearch team found the name misleading, because it suggested a stronger guarantee than the system actually gave, and they replaced it with the more honest wait_for_active_shards in the 5.0 series. In the same period, and in later versions, the replication machinery itself was strengthened with sequence numbers and checkpoints, which let the system repair copies much more reliably after failures. Today the setting is a small, well-defined control on top of a robust replication design.

i
Word check

Whenever this article says “active,” it means a shard copy that is assigned to a node and has finished starting up, so that it can take part in searches and writes. A copy that is unassigned, or that is still copying its data from another node, is not active yet.

TThe Problem: Writes When Copies Are Missing

A healthy cluster has all its copies ready. Real clusters are not always healthy. To see why this setting exists, look at what happens to writes when copies go missing.

Copies go missing all the time

A shard copy can be unavailable for many ordinary reasons. A server is restarted for patching. A cloud provider replaces a machine. A network cable is unplugged, or a switch has a bad hour. A disk fills up and Elasticsearch stops using it. A node runs out of memory and is restarted by the operating system. A whole availability zone loses power. In each case, some shard copies disappear from the cluster for seconds, minutes or hours, and the cluster starts rebuilding them elsewhere.

What the default does in those moments

With the default setting of 1, a write needs only the primary copy. If a replica is missing, the write goes ahead on the primary alone and succeeds. The client sees a normal success. The cluster status turns yellow, which means “all primaries are fine but some replicas are missing,” but the application usually never looks at the cluster status. During this window the newest data has no backup.

This is a sensible default for many workloads, because it keeps writes flowing. A logging system that receives a million events per minute would rather keep accepting them than stop during a patch. But for some data, a single-copy period is a risk worth avoiding: financial records, orders, medical events, anything expensive or impossible to recreate.

The choice: refuse or accept

The heart of the matter is a choice between two values. Availability means that the system keeps working. Safety means that the system does not accept data unless it can protect it properly. When copies are missing, you cannot have both fully. The setting lets you decide, index by index or request by request, where to stand.

SituationWith the default (1)With a stricter value (for example 2)
All copies healthyWrites succeed, replicated everywhereWrites succeed, replicated everywhere
One replica missing, one replica aliveWrites succeedWrites succeed, since the primary plus one replica are still active
All replicas missingWrites succeed on the primary alone, with no backupWrites wait and then fail after the timeout
Primary missing and no replacement readyWrites wait and then fail, since a primary is always requiredWrites wait and then fail

Why the confusion?

Many people assume that a setting with the word “consistency” in its history must guarantee that every write reaches a quorum, as some databases do. Elasticsearch does not work that way. It does not vote on each write. Its design is that the primary applies the write, sends it to all the copies it currently knows to be in step, and only then replies. Which copies count as “in step” is tracked by the cluster’s master node. The setting wait_for_active_shards does not change that design. It only adds a gate at the start. This distinction is the source of most misunderstandings, and it is why this article spends time on the internal working in Chapter 5.

Everyday analogy

Picture a photographer at a wedding who carries two memory cards so that every picture is saved twice. If one card fails, the photographer can continue on the other, but the pictures taken during that time have no backup. A careful photographer may decide: “If one card fails, stop and replace it before taking any more pictures of the ceremony.” That costs a few missed moments but guarantees no picture exists on only one card. Another photographer prefers never to miss a shot. Both are reasonable, and the right choice depends on how precious the pictures are.

Example: the order book

An online retailer at the scale of Amazon writes every customer order into a search index that also powers the “my orders” page. Losing even a few minutes of orders would mean real customers with real payments and no record. Such a business might choose to require at least two active copies for that index and accept that writes will be briefly refused if a replica is missing, with the application retrying.

Example: the firehose

A streaming service such as Netflix collects enormous volumes of playback events. If a few seconds of events are lost in a rare double failure, the effect on dashboards is invisible. Refusing writes during a routine restart would cause much more harm than a small chance of loss. For such data, the default is the sensible choice.

Refusing a write is sometimes the safest thing a database can do, and sometimes the most expensive.

The rest of this article gives you the tools to decide, for each of your indices, which side of that line is right.

CCore Concepts: The Vocabulary You Need

A dozen words unlock the whole subject. Each one is explained with what it is, why it exists, where you meet it, and a picture from everyday life.

Shard and shard copy

An index is divided into shards, and each shard is a self-contained slice of the data that can be stored on one node. To protect against failure, each shard exists in more than one copy. A copy is a full, independent version of that slice. Think of a shard as a chapter of a book, and copies as photocopies of that chapter kept in different rooms.

Primary and replica

Among the copies of a shard, exactly one is the primary. It is the one that receives every write first. The others are replicas. They receive the writes from the primary and serve searches too. If the primary is lost, one of the replicas is promoted to become the new primary. The primary is the editor-in-chief of the chapter; replicas are the copy editors who keep identical versions.

Number of replicas

The index setting number_of_replicas decides how many replica copies each shard should have. With 1 replica, each shard has 2 copies in total. With 2 replicas, 3 copies. This number is the target, the number the cluster tries to reach. The number of copies actually alive at a given moment may be lower.

Active copy

A copy is active when it is assigned to a node and has finished starting, so it is ready for work. A copy that is unassigned, or that is still copying its data from another node in a process called recovery, is not active yet. The setting wait_for_active_shards counts active copies.

The in-sync set

The master node of the cluster keeps a list, for each shard, of the copies that are known to be fully up to date. This list is called the in-sync set. When the primary applies a write, it sends the operation to every copy in the in-sync set and waits for their answers. A copy that fails to keep up is removed from the set, and stops counting until it is repaired. The in-sync set is like the list of committee members who have read all the latest minutes.

Sequence numbers and checkpoints

Every write to a shard receives a growing sequence number, like a numbered page in a ledger. Each copy tracks how far it has caught up, and the cluster tracks the point up to which all in-sync copies have everything, known as the global checkpoint. These numbers let a lagging copy catch up by replaying only what it missed, and let the cluster decide safely which copy can become primary after a failure.

Acknowledgment

When a write is finished, the client receives an acknowledgment, the response that says “done.” In Elasticsearch, this response arrives only after the primary and all in-sync replicas have applied the write, and, with the default durability rule, have safely recorded it to disk. So an acknowledgment is a genuine statement about safety, but it counts the copies that were in sync at that moment, which may be fewer than the target.

The timeout

If the required number of active copies is not available, the write does not fail at once. It waits, hoping that copies will become active, for a period set by the timeout parameter, which is one minute by default. If the copies are still not ready when time runs out, the write fails with an error saying that there are not enough active shard copies. It is like a shop assistant who says “please wait a minute while I find the second key” and, if none appears, says “sorry, I cannot help.”

The three kinds of values

The setting accepts three kinds of values. A number from 1 up to the total number of copies (the primary plus the replicas) means “at least this many copies must be active.” The word all means “every copy the index should have.” The default of 1 means “just the primary.” A number larger than the total number of copies is rejected as impossible.

Slice

Shard

One self-contained piece of an index, stored on a node.

Backup

Copy

A full version of a shard: the primary or one of its replicas.

Leader

Primary

The copy that receives each write first and directs the others.

Ready

Active

A copy that is assigned and fully started, so it can do work.

Up to date

In-sync set

The list of copies known to hold every acknowledged write.

Ledger

Sequence number

A growing number that orders every write to a shard.

Answer

Acknowledgment

The response that says the write was applied and safely recorded.

Patience

Timeout

How long a write waits for enough active copies before failing.

i
Remember

Copy, active, in-sync, acknowledgment, timeout. If you keep only five words in your head, keep these. The setting counts active copies before the write starts, the in-sync set decides who receives the write, and the acknowledgment tells you how it went.

AArchitecture and Components

Now let us zoom out and look at the machinery: which parts take part in a write, where each one lives, and where the “enough active copies” check fits in.

The setting wait_for_active_shards is not a separate service. It is a check built into the normal path that every write follows. The diagram below shows that path, with the gate that the setting controls drawn in as a decision.

flowchart LR
    CL["Client"] --> CO["Coordinating node"]
    CO --> GATE{"Enough active shard copies?"}
    GATE -->|"Yes"| P["Primary shard on node A"]
    GATE -->|"No - wait up to the timeout"| ERR["Error - not enough active copies"]
    P --> R1["Replica shard on node B"]
    P --> R2["Replica shard on node C"]
    R1 -->|"acknowledges"| P
    R2 -->|"acknowledges"| P
    P --> RESP["Response with successful and total copies"]
    M["Master node - keeps routing table and in-sync lists"] -.-> GATE
    M -.-> P
Figure 1. The path of a write, with the gate that wait_for_active_shards controls at the start.

Walking through the diagram

A client, such as an application or a log shipper, sends a write to any node of the cluster. That node becomes the coordinating node for the request: it works out which shard the document belongs to and finds where that shard’s primary lives. Before the write is applied, the cluster looks at the gate: are enough copies of that shard active? The answer comes from the cluster’s routing table, a map of every shard copy and its state, which the master node maintains and shares with all nodes. If enough copies are active, the write goes to the primary shard. If not, the write waits, and if the copies do not appear before the timeout, it ends with an error.

After passing the gate, the primary applies the write and sends it to the replicas on other nodes. Each replica applies it and answers. When all the copies in the in-sync set have answered, the primary replies, and the response travels back to the client, carrying counts of how many copies took part. The master node does not handle the write itself. It only maintains the map and the in-sync lists that the other parts rely on.

Everyday analogy

Think of a newsroom with an editor-in-chief (the primary) and two copy editors (replicas) in different offices. A reporter (client) hands a story to the front desk (coordinating node). The front desk looks at the staffing board kept by the office manager (master node) and asks: “Are enough editors in today?” If yes, the story goes to the editor-in-chief, who edits it, sends it to the copy editors, and waits for their confirmation before telling the reporter it is done. If not enough editors are in, the reporter waits at the desk for a while, and eventually is told to come back later.

The components in detail

ComponentWhat it doesWhere it lives
ClientSends writes and chooses the parameters, such as the active copy requirement and the timeoutYour application, agent or tool
Coordinating nodeRoutes the write to the right shard and waits for the outcomeAny node that receives the request
Routing tableRecords every shard copy, where it is assigned and whether it has startedThe cluster state, on every node
Master nodeMaintains the cluster state and the in-sync lists, and promotes replicas when a primary is lostThe elected master among master-eligible nodes
Primary shardApplies each write first, numbers it and forwards it to the replicasA data node
Replica shardsApply the same operations and serve searchesOther data nodes, ideally in other zones
Transaction logRecords each operation on disk so it survives a crashEvery shard copy
Index settingsStore the number of replicas and the default active copy requirementThe cluster state

Where copies should live

The setting counts copies, but copies are only useful if they are on different machines. Elasticsearch never puts a replica on the same node as its primary. For stronger safety you can also tell it about your zones or racks, using allocation awareness, so that copies of the same shard are spread across them. Requiring two active copies is much more meaningful when the two copies cannot be lost by a single power failure.

!
Tip

Before tuning wait_for_active_shards, check the physical layout of your copies. A requirement of two active copies that are both in the same rack protects you against one failing disk, but not against the rack losing power.

IInternal Working: What Really Happens During a Write

This is the engine room. You do not need to be an expert in distributed systems, because every idea comes with a picture.

sequenceDiagram
    participant C as Client
    participant N as Coordinating node
    participant P as Primary shard
    participant R as Replica shard
    C->>N: Write with wait_for_active_shards
    Note over N,P: Before the write starts, the required number of active copies is checked
    N->>P: Forward the write to the primary
    P->>P: Validate, apply and number the operation
    P->>R: Send the operation to each in-sync replica
    R-->>P: Apply and acknowledge
    P-->>N: Result with counts of copies
    N-->>C: Response
Figure 2. The steps of a write. The check happens once, at the start.

Step one: the check

When the write arrives, the cluster compares two numbers: how many copies of the target shard are active, and how many your setting requires. If the active count is high enough, the write proceeds at once. If not, the write does not fail immediately. Instead it waits, and each time the cluster’s picture of the shard copies changes, for example because a replica finished starting, the check is repeated. This continues until the requirement is met or the timeout expires. In the second case the write fails with an error, and importantly, nothing has been written for that shard.

Step two: the primary applies the write

The primary validates the operation, applies it to its own copy of the data, and gives it the next sequence number. It also records the operation in its transaction log, a file that lets the shard recover its recent changes after a crash. Because every operation passes through the primary, the primary is the single place where the order of writes is decided, which is what keeps all copies consistent with each other.

Step three: forward to the in-sync copies

The primary sends the operation, in parallel, to every copy in the in-sync set. This is the crucial point, and the source of the most common misunderstanding. The replication does not stop at the number you gave to wait_for_active_shards. If three replicas are in sync, the write goes to all three, even if you asked for only two active copies. The setting is a gate at the start, not a limit on the copying.

Step four: wait for the answers

Each replica applies the operation, records it in its own transaction log, and answers. With the default durability setting, each copy flushes the log to disk before answering, so an acknowledged write has survived on every copy that answered. The primary waits for all in-sync copies.

Step five: handle a copy that fails

What if a replica does not answer, or reports an error? The primary does not fail the write. Instead it tells the master node that this copy has fallen out of step. The master removes the copy from the in-sync set, and the copy is marked as failed and scheduled for repair. Only after that does the primary acknowledge the write to the client. The response then reports that one copy failed. This is how a write can succeed even though a replica failed during it, and it is exactly the case that the pre-write check cannot prevent.

Step six: the response

The response to a successful write includes a small section describing the shards. It has three numbers: the total number of copies that the shard is supposed to have, the number of successful copies that applied the write, and the number of failed copies. A response with a total of 3, three successful and none failed means all is well. A response with total 3, successful 2, failed 1 means that one replica errored during the write and is being repaired. A response with total 3, successful 1 and failed 0 means that two copies were not active at all when the write ran, so they were never even tried. Reading these numbers is the only way to see how well protected a particular write was.

Everyday analogy

Think of a teacher who dictates a sentence to three students and waits for all three to write it down before moving on. If one student’s pen runs dry, the teacher notes “student three missed it, will copy from a neighbor later” and continues. The lesson is not cancelled. The sentence has been recorded by two students, and the teacher’s note tells you exactly what happened.

Fencing off old primaries

What if the primary itself is lost, and a replica is promoted? Each time a new primary is chosen, a counter called the primary term goes up by one, and every operation carries it. Copies refuse operations that come with an older term. So if a slow or disconnected old primary wakes up and tries to send operations, the copies reject them. This fencing prevents two primaries from both accepting writes for the same shard and creating conflicting histories.

The guarantee, in plain words

Putting it together: when you receive a success response, the write is safely recorded on the primary and on every copy that was in sync at that moment. If the primary is lost afterward, the cluster promotes a copy that is in the in-sync set, so it has the write. The write can only be lost if all the copies that held it are lost together, for example, a primary with no active replicas at the time of the write. And that is exactly the exposure that wait_for_active_shards lets you shrink: by requiring at least two active copies, you make sure that when the primary applied the write, at least one other copy was ready to receive it.

QuestionAnswer
Is the check made before or after the write?Before. Nothing is written if it cannot be met before the timeout.
Does the write go only to the number of copies I asked for?No. It goes to all copies that are in sync at that moment.
Can a replica fail during the write?Yes. The write can still succeed, and the response reports the failed copy.
Can two primaries accept writes at once?No. The primary term fences off any old primary.
How do I see how many copies got the write?Read the shard counts in the response.

DData Flow and Lifecycle

Every write passes through a short life: it arrives, sometimes waits, is applied, replicated and acknowledged, or times out. Knowing each stage helps you read errors and slow responses.

stateDiagram-v2
    [*] --> Received
    Received --> Waiting : not enough active copies
    Received --> Applying : enough active copies
    Waiting --> Applying : copies become active
    Waiting --> TimedOut : timeout reached
    Applying --> Replicating : primary applied the operation
    Replicating --> Acknowledged : in-sync copies confirmed
    TimedOut --> [*]
    Acknowledged --> [*]
Figure 3. The life of a write. The waiting state exists only if the required copies are not yet active.

Stage one: received

The coordinating node accepts the request, works out the target shard and looks at the requirement: either the value given in the request, or, if none was given, the default stored in the index settings. Then it checks the routing table.

Stage two: waiting, if needed

If the requirement is not yet met, the write is parked. It costs almost nothing while it waits, since it holds no locks on data, but the client is waiting too. The write leaves this state in one of two ways: the missing copies become active, and the write moves on, or the timeout ends, and the write fails.

Stage three: applying and replicating

Once through the gate, the primary applies the write and forwards it to the in-sync copies. From this point the write is committed to happening. The setting has no further role.

Stage four: acknowledged

The response returns with the shard counts. In the normal case, all copies succeeded. In a degraded case, some copies are missing or failed, and the counts tell you.

The timeout ending

When the timeout expires, the write fails with an error that says there are not enough active copies, and states how many were needed and how many were found. The status code of the response is the kind used for “service unavailable,” which tells your client that a retry may succeed later. Because the check happens before the write starts, a failure of this kind means the write did not begin on that shard, so retrying it is safe from the point of view of duplicates. Timeouts on the client side are different: if your own client gives up waiting before the cluster answers, you cannot know whether the write happened, and you should make retries safe by using explicit document identifiers.

1

Send

The application sends a write with a required number of active copies, or relies on the index default.

2

Check

The cluster compares active copies with the requirement, and waits if needed.

3

Apply

The primary applies and numbers the operation, then forwards it to all in-sync copies.

4

Confirm

The copies apply the operation and answer, and any failing copy is removed from the in-sync set.

5

Respond

The client receives success with the shard counts, or an error if the requirement was not met in time.

6

Repair

In the background, missing or failed copies are rebuilt and rejoin the in-sync set.

Bulk requests and many shards

A bulk request contains many writes, aimed at many different shards. The requirement is checked per shard. If the shards of the target index have enough active copies for some documents and not for others, the documents for the healthy shards succeed and those for the unhealthy shards fail individually, each with its own error inside the bulk response. This is why you must always read the per-item results of a bulk response, and not just the overall status.

OutcomeWhat it meansWhat to do
Success, all copies successfulFully replicated at the time of the writeNothing, this is the normal case
Success, some copies failedA replica failed during the write and is being repairedWatch that repair completes; consider alerting
Success, fewer copies than total but none failedSome copies were not active, and the requirement allowed itCheck cluster health; consider a stricter setting
Failure, not enough active copiesThe requirement was not met before the timeout, and nothing was writtenRetry with backoff; investigate missing copies
Client timeout with no responseUnknown whether the write happenedUse explicit identifiers so retries are safe
!
Watch out: reading only the status code

A bulk request can return a normal overall status while some individual items failed. If your code checks only the overall status, it will silently drop the failed documents. Always look for the errors flag in the bulk response and process the failed items.

YYour First Tuning: A Guided Tour

Before going deeper, here is the route you follow when you decide to tune this setting for the first time. Knowing the road makes the later chapters easier to follow.

The setting itself is tiny. The thinking around it is what matters. Here is the journey for a beginner who wants to protect an index of customer orders.

Before you begin

Check four things. First, how many replicas does the index have? If it has none, then there is nothing to wait for, and the first task is to add a replica. Second, how many data nodes and zones does the cluster have? Copies must live on different nodes, so you need at least as many nodes as copies. Third, what is the current health of the cluster? If it is already yellow because replicas cannot be placed, a stricter setting will simply block writes. Fourth, what happens in your application when a write fails? If it just drops the data, a stricter setting can cause loss instead of preventing it.

1

Classify your indices

Sort them by value: irreplaceable business records, useful but recreatable data, and disposable data such as debug logs.

2

Check the copy layout

Confirm the number of replicas, the number of data nodes and zones, and that copies really are spread across them.

3

Choose a value on paper

For a valuable index with two replicas, choose 2: the primary plus at least one replica. For a disposable one, keep the default.

4

Decide where to set it

On each request, or as an index default. For a whole index that always needs the rule, the index default is safer, since it cannot be forgotten.

5

Prepare the application

Make sure it reads write errors, retries with backoff, uses explicit identifiers, and has a sensible timeout.

6

Rehearse a failure in a test cluster

Stop a node that holds a replica, and watch what your writes do: whether they wait, fail or succeed, and how your application reacts.

7

Roll out and watch

Apply the setting to production, watch the rate of write errors and the cluster health, and be ready to adjust.

8

Write it down

Record the value, the reason, and the expected behaviour during restarts, so that the next engineer understands the choice.

Everyday analogy

Choosing the value is like setting the safety rule at a factory. You first decide which machines are dangerous, then write a rule for each: “this press needs two operators present,” “this small drill needs one.” Then you train the workers on what to do when a second operator is missing, and you hold a drill. A rule that nobody has practiced tends to cause confusion on the day it matters.

!
Tip

Do your first rehearsal on a test cluster with the same number of replicas as production. Stopping one node and watching the write behaviour for five minutes teaches more than an hour of reading.

!
Watch out: hosted deployments

On hosted cloud deployments, rolling changes, plan changes and maintenance move nodes around automatically, and replicas are unavailable for short periods during them. A strict setting will interact with that maintenance, so check what your platform does and test with its behaviour in mind.

TThe Values: 1, a Number, or “all”

The setting accepts only a few kinds of values. This chapter shows exactly what each one means, how to calculate the right number, and what happens when the number is impossible.

Start with the arithmetic

Every shard has one primary and some number of replicas, so the total number of copies is always one plus the number of replicas. With 0 replicas, a shard has 1 copy. With 1 replica, 2 copies. With 2 replicas, 3 copies, and so on. The value you give to wait_for_active_shards must be between 1 and that total. Anything higher is impossible to satisfy and is refused.

ReplicasTotal copiesAllowed valuesWhat “all” meansMajority of copies
011Just the primary, same as the default1
121 or 2Primary and the replica, so 22
231, 2 or 3All three copies2
341 to 4All four copies3
451 to 5All five copies3

The default: 1

The default requires only the primary. It is the most available choice: as long as the primary exists, writes go ahead, however many replicas are missing. It matches the way most search and log workloads are used, and it is the right choice for the great majority of indices.

A number: at least this many active

Choosing a number such as 2 means “the primary and at least one replica must be active.” This is the most common way to tighten the rule. Its value depends on how many replicas you have. With exactly one replica, 2 is the same as “all,” and any missing replica blocks writes. With two replicas, 2 lets you lose one replica and keep working, while still guaranteeing that every write finds at least one partner copy ready.

The word “all”

The value all means that the primary and every replica must be active. It gives the strongest protection at the start of a write, and it is also the most fragile: the loss of any single copy, even for a routine restart, blocks writes on that shard until the copy is back. Use it only when you truly need every copy present, and be ready to see write errors during each maintenance event.

The majority pattern

Many distributed systems use a “majority” or “quorum,” meaning more than half of the copies. You can imitate this pattern by choosing a number equal to the total divided by two, rounded down, plus one. With three copies, that is 2. With five, 3. This gives a good balance: it tolerates the loss of a minority of copies, and guarantees that each write starts with a majority ready. Remember, though, that Elasticsearch does not vote on writes. The pattern only sets the entry rule, and the replication itself still goes to all in-sync copies.

Everyday analogy

Imagine a jury room. “One” means the trial can start as long as the judge is present. “Two” means the judge and at least one juror must be present. “All” means every juror must be present, so a single sick juror postpones the trial. “Majority” means enough people are there to make a decision that will stand. Each rule is a different balance between getting on with the work and getting it right.

Impossible values

If you ask for a number larger than the total number of copies, for example 3 on an index with one replica, Elasticsearch rejects the request with a validation error right away, rather than waiting for the timeout. The message says that the number of active copies to wait for cannot be greater than the number of copies of the shard. Negative numbers are rejected too. A related trap is asking for “all” on an index whose replicas can never be placed, for example one replica on a cluster with a single data node. Then the replica is permanently unassigned and every write will wait until the timeout and fail.

Interaction with changing replica counts

The value “all” is not a fixed number. It follows the index’s configured number of replicas at the moment of the write. If someone changes the replica count, what “all” requires changes with it. Some indices use automatic expansion of replicas, which grows or shrinks the count with the number of nodes, and there “all” moves too. If you want a fixed rule, use a number.

Zero for index-level operations

For some operations that create or open indices, and depending on the version, a value of zero may be accepted, meaning “do not wait for any shard at all.” This is rarely wise, because the response would return before anything is ready to use. Check your version’s documentation before using it.

!
Watch out: single-node clusters

On a development machine with a single node, replicas cannot be placed anywhere, so every index is permanently yellow. A stricter value than 1 will make every write wait and fail. Set the number of replicas to zero on single-node test clusters, or keep the default.

!
Tip

Write down the formula next to the setting: total copies equal one plus replicas, and the value must not exceed it. The mistakes that beginners make with this setting are almost always arithmetic mistakes.

WWhere to Set It: Requests, Indices and Templates

The same rule can be given in several places. Knowing which one wins, and which one is best, saves many surprises.

On the individual request

Every write operation accepts the parameter. You can put it on a single document write, an update, a delete, or a bulk request, along with the timeout. When you do, it applies to that request alone. This is the most flexible option, and it suits special cases: a critical write that needs a stricter rule than usual, or a big backfill that should not be blocked by a single missing replica. The drawback is that every writer must remember to send it, which is easy to forget when many tools and teams write to the same index.

As an index default

The second place is the index itself. Each index has a setting, named index.write.wait_for_active_shards, that acts as the default for all writes to that index. It is a dynamic setting, so you can change it on a live index and it takes effect immediately. If a request does not carry its own value, the index default applies. If the index does not have one either, the global default of 1 applies. This is the best place for a rule that should always hold, since it works even for tools that cannot send the parameter, such as many log shippers and agents.

PlaceScopeWins overBest used for
Request parameterOne requestThe index default and the global defaultExceptions to the normal rule
Index settingAll writes to that indexThe global defaultA standing rule for an important index
Global default (1)EverythingNothingOrdinary and disposable data

In index templates

Time-based data creates new indices constantly: one per day, or a new backing index whenever a data stream rolls over. Setting the rule on each new index by hand would be impossible. Instead, put the setting into the index template that matches those names. Every new index then arrives with the rule already in place. For data streams, the template of the stream carries the setting to each backing index. Do not forget to update the template when you change your policy, since the older indices keep the value they were born with until you change them.

For tools that cannot send parameters

Many ingestion tools send their writes without any option for this parameter. That is not a problem if you use the index default, because the rule lives in the cluster, not in the tool. This is a strong argument for setting the rule on the index or the template, and using the request parameter only for exceptions.

Which operations honour it

OperationWhat the requirement means
Index, create, update, deleteThe write does not start until enough copies of the target shard are active
BulkThe same rule, checked separately for each shard that the bulk touches
Update by query and delete by queryThe operation waits for enough active copies before it begins its work
ReindexThe job waits for enough active copies of the destination before proceeding
Create index, open indexThe call does not return until enough shard copies have started, or the timeout ends
Rollover, shrink, split, cloneThe same waiting rule applies to the new index that these operations create

The timeout goes with it

Each of these operations has a companion timeout, the time it is willing to wait for the copies. The default is one minute. Shorten it if your users cannot wait, and lengthen it if you are willing to wait through a restart. A stricter requirement with a very short timeout produces many quick failures during any disturbance. A stricter requirement with a longer timeout produces slow writes but fewer failures. Choose the pair together.

Everyday analogy

A company can put a rule in a memo to every employee (a request parameter), or it can build the rule into the door lock so it works whoever walks up (an index setting). The lock is far more reliable, since it does not depend on everyone remembering. The memo is useful for exceptions: “for this delivery only, please use the side door.”

!
Tip

Make the index template the source of truth for your rule, and check the effective settings of a few real indices from time to time. A template that was updated last month does not fix indices created the month before.

FFour Meanings of “Consistency” in Elasticsearch

The word “consistency” is used for several different ideas. Mixing them up is the most common reason people tune the wrong knob.

When someone says “I want my writes to be consistent,” they might mean any of four quite different things. Each is controlled by a different setting. Separating them will save you a lot of confusion, and it will show exactly where wait_for_active_shards fits.

Meaning one: enough copies ready

This is the topic of this article. It asks: how many copies must be alive before I accept a write? It controls the protection at the moment the write begins. The knob is wait_for_active_shards, together with the number of replicas.

Meaning two: is it safely on disk?

This asks: when the response says “done,” has the data been saved on disk, so it survives a crash of the machine? Elasticsearch records each operation in a transaction log on every copy. By default, the log is flushed to disk before each request is acknowledged, which is called request durability. You can relax this so that the log is flushed on a timer, by default every five seconds. That makes writes faster but means that a crash might lose the last few seconds of acknowledged writes on that copy. The knob here is the transaction log durability setting and its sync interval. Even with the relaxed setting, other copies still hold the data, which is another reason for replicas.

Meaning three: can a search see it yet?

This asks: after my write succeeds, will a search find the document immediately? Elasticsearch is called near real-time: a new document becomes searchable only after the next refresh, which by default happens about once per second. Fetching a document by its identifier is immediate, but searching is not. The knobs are the refresh interval of the index and the refresh option on a write, which can force a refresh or wait for the next one. This is a question about visibility and has nothing to do with the number of copies.

Meaning four: what if two writers collide?

This asks: if two clients update the same document at nearly the same time, what happens? Elasticsearch uses optimistic concurrency control: each document carries a sequence number and a primary term, and an update can say “apply only if the document is still at this sequence number.” If someone else changed it first, the update is refused, and the client can re-read and try again. The knobs are the sequence number and primary term conditions, or version checks. It prevents lost updates between clients, and is unrelated to how many shard copies are alive.

QuestionWhat it protectsMain knobs
Are enough copies ready before I write?Redundancy at the start of the writewait_for_active_shards, number of replicas, timeout
Is it safely on disk when acknowledged?Survival of a machine crashTransaction log durability and sync interval
Can a search see it right away?Read-your-writes visibilityRefresh interval, refresh option on the write
What if two writers collide?Correct concurrent updatesSequence number and primary term conditions, versions
Everyday analogy

Think of a library receiving a new book. Meaning one is whether enough shelves and librarians are ready to accept it. Meaning two is whether the book has been written into the permanent register, in ink. Meaning three is whether it has been placed on the public shelf where visitors can find it. Meaning four is what happens if two librarians try to relabel the same book at once. All four are “keeping the library consistent,” but each has its own procedure.

Why cluster health is another thing again

The cluster health interface has its own option, wait_for_status, which makes the call wait until the whole cluster reaches a given colour: green, yellow or red. It looks similar but works at a different level. It waits on the whole cluster, and is used by scripts that want to hold until the cluster has settled. The write setting works per shard, per operation.

Example: the search that does not find the new order

A support engineer at a retailer sees a customer’s order confirmed on the screen, but a search for it returns nothing for a second. She suspects a problem with the write settings. In fact, the write succeeded on every copy, and the search was simply run before the next refresh. Tuning wait_for_active_shards would not change anything. The right fix, if instant visibility matters, is to have the application wait for a refresh on that write, or to fetch the document directly by its identifier.

!
Watch out: tuning the wrong knob

Raising wait_for_active_shards does not make searches see new data sooner, does not make each write safer on disk, and does not stop two clients from overwriting each other. It only changes how many copies must be ready before a write starts. Decide which of the four meanings you actually need before you touch a setting.

FFailure Scenarios: What Actually Happens

Theory becomes real when things break. This chapter walks through the common failures and shows how each value of the setting behaves.

flowchart TD
    F["Node holding a replica leaves the cluster"] --> D["Replica becomes unassigned"]
    D --> W{"Required active copies for writes"}
    W -->|"1"| A["Writes continue on the primary alone - single copy risk"]
    W -->|"2 with one replica"| B["Writes wait, then fail after the timeout"]
    W -->|"2 with two replicas"| C["Writes continue - primary plus one replica still active"]
    A --> R["Replica rebuilt on a node - redundancy restored"]
    B --> R
    C --> R
Figure 4. The same failure, three different requirements, three different outcomes.

Scenario one: a replica’s node restarts

A routine restart takes a node offline for about three minutes. The replicas on that node disappear. When a node leaves, Elasticsearch does not rush to rebuild its shards elsewhere, because most nodes come back quickly and rebuilding is expensive. It waits for a delay, one minute by default, before reallocating. During this time the affected replicas are unassigned. With the default rule, writes continue on the primaries alone. With a requirement of 2 and one replica, writes to the affected shards wait, and fail if the timeout of one minute is reached before the node returns. With a requirement of 2 and two replicas, the second replica keeps things going.

Scenario two: a node is lost for good

A machine dies and will not return. If it held replicas, they are rebuilt on other nodes after the delay. The rebuild takes time proportional to the amount of data, and until it finishes, the same trade-off applies. If it held primaries, a replica on another node is promoted to primary, within moments, and the shard continues, though with fewer copies until the rebuild completes. This is exactly the case where having required at least two copies pays off: the promoted primary is guaranteed to hold every acknowledged write.

Scenario three: a whole zone disappears

If the cluster is spread over three zones with zone-aware placement, losing one zone removes about a third of the copies of every shard. With two replicas, each shard still has at least two copies, and a requirement of 2 is still satisfied. With one replica and a requirement of 2, half the shards that had a copy in that zone now lack their second copy, and writes to those shards will wait. This is a clear example of why the requirement and the number of replicas should be chosen together.

Scenario four: a network partition

A network fault splits the cluster in two. The side that keeps a majority of master-eligible nodes continues; the other side cannot elect a master and stops accepting writes for its shards. Shard copies on the minority side are treated as lost by the majority side, and the majority promotes replacements. The fencing described earlier prevents old primaries on the minority side from causing damage when the partition heals. The requirement for active copies is judged by the side that has a master, using its own view.

Scenario five: the primary is lost

When a primary fails, writes to that shard cannot proceed until a replica has been promoted. Writes wait, at the gate or in the queue, and resume as soon as the promotion is complete, usually within seconds. If there is no in-sync replica to promote, the shard stays red and writes fail once the timeout passes, whatever value of the setting you use. No setting can create a primary out of nothing.

Scenario six: a rolling upgrade

During an upgrade, nodes are restarted one by one. At each restart, the replicas on that node are briefly missing. With a strict requirement and few replicas, each restart will cause a short period of write errors. With enough replicas, the requirement can stay satisfied throughout. Many teams temporarily relax the rule during upgrades, or add a replica before the upgrade begins.

ScenarioDefault (1)2 with one replica2 with two replicasall
One replica node restartsWrites continue on fewer copiesWrites wait, then may failWrites continueWrites wait, then may fail
One zone lost (three zones)Writes continueSome shards wait or failWrites continueMany shards wait or fail
Primary node lostBrief wait for promotion, then continueWait for promotion, then continue if the replica is activeBrief wait, then continueWait until all copies are back or rebuilt
All replicas lostWrites continue with no backupWrites failWrites failWrites fail
Cluster red for a shardWrites to that shard failWrites to that shard failWrites to that shard failWrites to that shard fail
Everyday analogy

Think of a hospital ward where a policy says “a surgery may start only if two qualified surgeons are on site.” On a normal day the rule costs nothing. If one surgeon is delayed, non-urgent surgeries wait, which is annoying but safe. If three surgeons are on call, one delay changes nothing. The rule looks very different depending on how many people you have to spare.

!
Tip

Hold a small failure drill for each critical index: stop a replica’s node, watch the writes, then bring it back. Record how long writes waited and how long it took for the cluster to become green. These two numbers tell you whether your setting matches your reality.

CChoosing a Value: A Practical Method

There is no single right value. There is a right value for each kind of data. This chapter gives a simple method to find it.

flowchart TD
    Q["How valuable is each write?"] --> A{"Can you afford to lose a recent write if a node is lost?"}
    A -->|"Yes"| B["Keep the default of 1"]
    A -->|"No"| C{"Does the index have at least two replicas?"}
    C -->|"Yes"| D["Use 2 - primary plus one replica, and one replica may be down"]
    C -->|"No"| E{"Can writes pause during restarts and failures?"}
    E -->|"Yes"| F["Use 2 with one replica - same as all"]
    E -->|"No"| G["Add a replica first, then use 2"]
Figure 5. A quick decision chart for choosing a value for one index.

Step one: decide what a lost write costs

Ask a plain question: if the newest few minutes of writes vanished in a rare double failure, what would happen? For debug logs, nothing. For product page views, a small dent in a chart. For customer orders or payment records, angry customers, refunds and possibly legal trouble. The answer sets how much inconvenience you should accept in order to reduce the chance.

Step two: decide what a refused write costs

Now ask the opposite question: if writes were refused for a few minutes during a restart, what would happen? If a durable queue sits in front of Elasticsearch and can hold the events until the cluster is ready, a pause costs almost nothing. If users are typing data into a form and each refused write shows an error page, a pause is expensive. This second question is often forgotten, and it is just as important as the first.

Step three: fix the number of replicas first

The setting is limited by the number of replicas, so decide that first. With zero replicas, there is no redundancy, and nothing to wait for. With one replica, you get single-failure protection, but a strict rule makes every replica outage block writes. With two replicas, you can be strict and still tolerate one replica being unavailable. For truly valuable data, two replicas plus a requirement of 2 is a well-proven combination. It costs an extra copy of storage, and it buys resilience through restarts, upgrades and single failures.

Step four: pick the value

Type of dataReplicasSuggested valueWhy
Disposable logs and debug data0 or 11 (default)Availability matters more than the last few seconds
Routine application logs and metrics11 (default)A small window of risk is acceptable; a queue may already protect the data upstream
Product catalog, content, search data recreatable from a database11 (default)The source of truth is elsewhere, and a rebuild is possible
Security and audit records22Losing evidence is costly, and one replica may be down without blocking
Orders, payments and other business records22Each write should start with at least two copies ready
Data that must never exist on fewer than every copy1 or 2allRare; accept that any missing copy blocks writes

Step five: pair it with a timeout and a plan

A stricter rule needs a partner: a timeout that fits the kind of disturbance you expect, and a client that knows what to do when a write is refused. For batch pipelines, a longer timeout and a queue are natural. For interactive applications, a short timeout and a clear message for the user may be right.

Step six: test and revisit

Try the choice in a rehearsal, as described earlier, and revisit it whenever the cluster changes size, when you add zones, or when the business value of the data changes. A rule chosen when the cluster had three nodes may not fit a cluster of thirty.

Everyday analogy

Choosing the value is like choosing how many locks to put on a door. A garden shed needs one. A house needs two. A bank vault needs several, and staff to open them. Every extra lock protects better and makes it slower and more annoying to get in. You fit as many as the valuables inside deserve, and no more.

Example: a payments ledger search

A payments company such as Stripe or PayPal keeps a searchable index of transactions for its support and risk teams. The system of record is a database, but the search index is used to investigate disputes. The team decides that the index should hold two replicas, set the requirement to 2, and let a durable queue in front of Elasticsearch absorb writes during any disturbance. Restarts cause no lost data and no errors for users, and the price is one extra copy of the data.

!
Tip

When in doubt, prefer adding a replica over raising the requirement. An extra replica makes the same rule easier to satisfy and also helps reads and recovery. A stricter rule without spare copies mainly makes writes fragile.

BBeyond Writes: Creating, Opening and Rolling Over Indices

The same setting also appears on operations that create or restore indices. Here the question is not “may this write begin?” but “when should I say the index is ready?”

Creating an index

When you create an index, Elasticsearch adds it to the cluster state and then starts allocating its shards to nodes. The create call has to decide when to return. By default it waits until the primary of each shard has started, then reports success. If you give a larger requirement, it waits until that many copies of each shard have started. When the timeout ends before that has happened, the call returns an answer that says the index was created but not yet ready. Two flags appear in the response. The first, acknowledged, says that the master accepted the creation. The second, shards_acknowledged, says whether the required number of shard copies started in time. A response with the first true and the second false is not an error: the index exists and is being prepared, it just was not ready in time.

flowchart LR
    CREATE["Create index request"] --> MASTER["Master adds the index to the cluster state"]
    MASTER --> ALLOC["Shard copies are allocated and started"]
    ALLOC --> CHK{"Required copies started before the timeout?"}
    CHK -->|"Yes"| OK["acknowledged true and shards_acknowledged true"]
    CHK -->|"No"| PART["acknowledged true and shards_acknowledged false"]
Figure 6. On index creation, the requirement decides when the call reports that shards are ready.

Why this matters to automation

Scripts often create an index and immediately start writing. With the default of 1, when the create call returns, every primary is started, so the first writes will succeed. If your script asks for a stricter number on creation and the cluster cannot start that many copies in time, the script will see the “not ready” flag, and should decide whether to wait, retry or stop. Ignoring that flag is a common source of confusing failures right after a deployment.

Opening a closed index

A closed index has no active shards. Opening it makes the cluster start them again, and the same requirement decides when the call returns. Opening a big index with many shards can take time, so the timeout and the requirement are worth considering, especially in scripted maintenance.

Rollover, shrink, split and clone

Operations that create a new index from an old one, such as rollover for time-based data, or resizing operations such as shrink, split and clone, accept the same parameter. It controls how long they wait for the new index’s shard copies to start before returning. For rollover in particular, this matters for data streams: after a rollover, new writes go to the new backing index, and the first writes will meet the requirement of that new index. Make sure the template of the stream gives the new index the same rule you gave the old one.

OperationWhat the requirement decidesWhat to check in the response
Create indexWhen to report that the new index’s shards are readyThe shards acknowledged flag
Open indexWhen to report that reopened shards have startedThe shards acknowledged flag
RolloverWhen to report that the new index is readyThe rolled over flag and the shards acknowledged flag
Shrink, split, cloneWhen to report that the resized index is readyThe shards acknowledged flag
Everyday analogy

Opening a new shop is like creating an index. “Acknowledged” means the city has approved the shop and the sign is up. “Shards acknowledged” means that enough staff have actually arrived and are at their counters. You can have a shop that is legally open but not yet properly staffed, and it is wise to look at both facts before announcing the grand opening.

Templates keep the rule alive

Because time-based data creates new indices all the time, only a template can guarantee that every new index carries the right default. Check that your lifecycle policies, rollover actions and data stream templates all produce indices with the setting you expect. A quick review of the settings of the newest index of each family, after a rollover, is a cheap way to be sure.

!
Watch out: created but not ready

A create call that returns “acknowledged” with the shards flag false has not failed, and retrying it will produce an error saying that the index already exists. Treat the flag as a signal to wait and check the health of the index, not as a reason to repeat the call.

PPerformance, Scalability and Reliability

A stricter rule has costs in speed, capacity and operations. This chapter shows where they appear and how to keep them small.

The check itself is cheap

In a healthy cluster, the gate takes almost no time: it is a comparison of two numbers using information every node already holds. Raising the requirement from 1 to 2 does not make healthy writes slower. This surprises many people, and it follows from the design: the primary already sends every write to all in-sync replicas and waits for them, whatever the requirement.

What does slow writes down

Write latency is driven by the number of in-sync copies and the speed of the slowest one. A primary waits for every in-sync replica, so a slow node, a busy disk or a distant zone in the copy set slows the write. Adding a replica adds one more copy to wait for, and therefore adds a little latency and a lot of extra network, processor and disk work. So the cost of durability is paid mostly through the number of replicas, not through the setting. Choose the number of replicas with that in mind, and use zones that are close to each other in network terms.

What the setting does change: behaviour during trouble

The setting shapes what happens when copies are missing. A strict rule turns a period of missing replicas into a period of waiting and errors. The waiting time is bounded by the timeout. During that time, requests pile up at the client or in the queue, so a strict rule requires a plan for backlog.

Timeouts that fit together

Three timeouts interact. The cluster-side timeout says how long the write waits for copies. The client-side timeout says how long your application waits for any answer. And the timeout of anything in between, such as a proxy or load balancer, says how long the connection may stay open. If the client gives up before the cluster does, the client does not learn the outcome, and you may see duplicates on retry. The safe pattern is: cluster-side timeout shorter than the client’s, and the client’s shorter than the proxy’s.

Retrying well

When a write fails because too few copies were active, the right response is to retry later, with a growing pause between attempts and a little randomness to avoid many clients retrying in step. Give up after a sensible limit, and put the write somewhere safe, such as a dead-letter queue, for later handling. Use explicit document identifiers so that a retry of a write that did in fact succeed replaces the same document and does not create a duplicate.

Retry

Backoff with jitter

Wait longer after each failure, and add randomness so clients do not retry in lockstep.

Retry

Explicit identifiers

Make retries harmless by giving each document a stable identifier.

Buffer

Durable queue

Let a queue hold events while copies recover, and replay them afterward.

Buffer

Dead-letter storage

Keep writes that repeatedly fail, so that nothing is lost silently.

Order

Timeouts in order

Cluster timeout shorter than client timeout, shorter than proxy timeout.

Read

Per-item results

Always inspect each item in a bulk response and handle failed ones.

Do not confuse it with backpressure

Elasticsearch can also refuse writes when it is overloaded, not when copies are missing. In that case the write queues are full, and the response is a “too many requests” error. That is a different problem, with a different cure: slow down, use smaller bulk requests, add capacity. The error for missing copies says the service is unavailable. Learn to tell them apart in your logs.

Capacity: leave room to rebuild

The strictness of your rule only helps if the cluster can rebuild lost copies quickly. That needs spare nodes and disk space. If a node with 2 terabytes of data is lost and the remaining nodes are nearly full, the replicas cannot be rebuilt anywhere and stay missing. A simple planning rule is to be able to lose one node, or one zone, and still have room to place all its copies elsewhere.

Speed of rebuilding matters too. The time during which writes are blocked, if your rule is strict and you have few replicas, is about the time to rebuild the affected shard. A shard of 50 gigabytes rebuilt at 100 megabytes per second takes 500 seconds, a little over eight minutes. A shard of 500 gigabytes takes about eighty-three minutes. This is one more reason to keep shards moderately sized, and it is why very large shards and very strict rules do not go well together.

Scale picture: a global ride-hailing platform

Imagine a company such as Uber that writes millions of trip and payment events every minute. Its payment index has two replicas across three zones and a requirement of 2. Events pass through a durable queue on their way to Elasticsearch. During a zone outage, writes to the affected shards continue on the remaining copies. During a rolling upgrade, each restart leaves at least one replica, so writes never pause. Meanwhile a huge, low-value index of location pings uses the default requirement with a single replica. The platform pays for the extra replica only where the data justifies it.

Reliability: the layers

Think of reliability as layers: replicas protect against machine loss, the requirement stops writes from being accepted with no backup, queues protect against pauses, snapshots protect against mistakes and larger disasters, and cross-region replication protects against the loss of a whole region. The setting in this article is one useful layer among these, and it works best in combination with the others.

AAdvantages, Disadvantages and Trade-offs

No setting is free. Knowing what a stricter requirement gives and takes helps you defend your choice when things go wrong.

Advantages of a stricter value

  • Stops the cluster from accepting writes that have no backup ready.
  • Shrinks the window in which one failure could lose newly acknowledged data.
  • Cheap to check, so it adds no delay in a healthy cluster.
  • Can be set per index, per template or per request, matching the value of the data.
  • Makes failures loud: a missing copy shows up as write errors, not silent risk.
  • Provides a clear, explainable rule for audits and reviews.
  • Combines well with queues and retries for resilient pipelines.

Disadvantages of a stricter value

  • Reduces availability: missing copies can block or fail writes.
  • Makes routine maintenance and upgrades visible to your applications.
  • Does not guarantee replication to that many copies after the write starts.
  • Does nothing for read visibility, durability on disk, or concurrent updates.
  • Needs enough replicas to be useful, which costs storage and processing.
  • Can be set impossibly high or on single-node clusters, blocking every write.
  • Requires clients that handle errors, retries and timeouts properly.

Trade-off one: availability versus durability

This is the central trade-off. The default favours availability: writes always go, even at the cost of a temporary single-copy state. A stricter value favours durability: writes wait until a backup is ready. In distributed systems language, you are choosing which of the two to give up a little of when a failure occurs. You cannot have both completely, and the setting lets you choose per index.

Trade-off two: strictness versus operations

The stricter the rule, the more your applications feel every maintenance event. If the operations team restarts a node every night for patching, a strict rule with one replica means nightly write errors. You can soften this by adding a replica, by pausing writes through a queue, or by choosing a slightly less strict value.

Trade-off three: cost versus safety

Each additional replica multiplies the storage and the write work. Two replicas cost roughly half again as much as one, and three cost twice as much. Reserve the expensive combination for data that deserves it.

Trade-off four: simplicity versus fine control

One global rule is simple to understand and audit. Per-index rules match the data better but must be managed, documented and kept in templates. Most teams settle on a small number of classes, such as “standard” and “critical,” and assign each index to one of them.

Comparing the options

OptionBehaviour when one replica is missingProtection at write startBest for
Default (1)Writes continue on fewer copiesPrimary onlyLogs, metrics, recreatable data
2 with two replicasWrites continue, at least two copies readyPrimary plus one replicaImportant business data
2 with one replicaWrites wait and may failPrimary plus the replicaData that must never be single-copy, with pauses accepted
Majority patternDepends on copy count; tolerates a minority missingA majority of copiesLarger replica counts and mixed needs
allWrites wait and may failEvery copyRare, special cases

These choices are not rivals of other protections. Snapshots, cross-region replication and upstream queues all cover different failures, and a mature design uses several of them together.