| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 | [role="xpack"][testenv="platinum"][[ccr-overview]]== Overviewbeta[]Cross-cluster replication is done on an index-by-index basis. Replication isconfigured at the index level. For each configured replication there is areplication source index called the _leader index_ and a replication targetindex called the _follower index_.Replication is active-passive. This means that while the leader indexcan directly be written into, the follower index can not directly receivewrites.Replication is pull-based. This means that replication is driven by thefollower index. This simplifies state management on the leader index and meansthat {ccr} does not interfere with indexing on the leader index.[float]=== Configuring replicationReplication can be configured in two ways:* Manually using the  {ref}/ccr-put-follow.html[create follower API]* Automatically using  <<ccr-auto-follow,auto-follow patterns>>NOTE: You must also <<ccr-requirements,configure the leader index>>.[float]=== The mechanics of replicationWhile replication is managed at the index level, replication is performed at theshard level. When a follower index is created, it is automaticallyconfigured to have an identical number of shards as the leader index. A followershard task in the follower index pulls from the corresponding leader shard inthe leader index by sending read requests for new operations. These readrequests can be served from any copy of the leader shard (primary or replicas).For each read request sent by the follower shard task, if there are newoperations available on the leader shard, the leader shard responds withoperations limited by the read parameters that you established when youconfigured the follower index. If there are no new operations available on theleader shard, the leader shard waits up to a configured timeout for newoperations. If new operations occur within that timeout, the leader shardimmediately responds with those new operations. Otherwise, if the timeoutelapses, the follower shard replies that there are no new operations. Thefollower shard task updates some statistics and immediately sends another readrequest to the leader shard. This ensures that the network connections betweenthe remote cluster and the local cluster are continually being used so as toavoid forceful termination by an external source (such as a firewall).If a read request fails, the cause of the failure is inspected. If thecause of the failure is deemed to be a failure that can be recovered from (for example, a network failure), the follower shard task enters into a retryloop. Otherwise, the follower shard task is paused and requires userintervention before the it can be resumed with the{ref}/ccr-post-resume-follow.html[resume follower API].When operations are received by the follower shard task, they are placed in awrite buffer. The follower shard task manages this write buffer and submitsbulk write requests from this write buffer to the follower shard.  The writebuffer and these write requests are managed by the write parameters that you established when you configured the follower index.  The write buffer serves asback-pressure against read requests. If the write buffer exceeds its configuredlimits, no additional read requests are sent by the follower shard task. Thefollower shard task resumes sending read requests when the write buffer nolonger exceeds its configured limits.Mapping updates applied to the leader index are automatically retrievedas-needed by the follower index.Settings updates applied to the leader index that are needed by the followerindex are automatically retried as-needed by the follower index. Not allsettings updates are needed by the follower index. For example, changing thenumber of replicas on the leader index is not replicated by the follower index.NOTE: If you apply a non-dynamic settings change to the leader index that isneeded by the follower index, the follower index will go through a cycle ofclosing itself, applying the settings update, and then re-opening itself. Thefollower index will be unavailable for reads and not replicating writesduring this cycle.[float]=== Inspecting the progress of replicationYou can inspect the progress of replication at the shard level with the{ref}/ccr-get-follow-stats.html[get follower stats API]. This API gives youinsight into the read and writes managed by the follower shard task. It alsoreports read exceptions that can be retried and fatal exceptions that requireuser intervention.[float]=== Pausing and resuming replicationYou can pause replication with the{ref}/ccr-post-pause-follow.html[pause follower API] and then later resumereplication with the {ref}/ccr-post-resume-follow.html[resume follower API].Using these APIs in tandem enables you to adjust the read and write parameterson the follower shard task if your initial configuration is not suitable foryour use case.[float]=== Terminating replicationYou can terminate replication with the{ref}/ccr-post-unfollow.html[unfollow API]. This API converts a follower indexto a regular (non-follower) index.
 |