Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Blog
  • Pricing
  • Documentation
© 2025 Direct Cursus Technology L.L.C.
Yandex Managed Service for MongoDB
  • Getting started
    • Resource relationships
    • Network in Yandex Managed Service for MongoDB
    • Quotas and limits
    • Storage in Yandex Managed Service for MongoDB
    • Backups
    • Replication and fault tolerance
    • Sharding
    • Users and roles
    • Maintenance
    • Supported clients
    • MongoDB settings
  • Access management
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Public materials
  • Release notes

In this article:

  • Fault tolerance
  • Assigning a different host as a master if the primary master fails
  1. Concepts
  2. Replication and fault tolerance

Replication and fault tolerance MongoDB

Written by
Yandex Cloud
Updated at February 18, 2025
  • Fault tolerance
    • Assigning a different host as a master if the primary master fails

Managed Service for MongoDB supports replication by default: if a cluster has multiple active hosts, they automatically select a primary replica to process write queries.

When changing the primary replica manually, MongoDB will automatically select a new primary replica from the available hosts.

For more information about how replication works in MongoDB, read the relevant documentation.

Fault toleranceFault tolerance

For cluster hosts to be able to automatically select the primary replica when needed, the absolute majority of hosts need to be healthy. This makes clusters with an odd number of hosts more cost-efficient to deploy. For example, a cluster with three hosts can lose one host and keep working. At the same time, a cluster with four hosts can also lose only one host: if a second host is lost, the remaining hosts will not be enough to select a new primary replica.

A cluster with two hosts does not ensure full fault tolerance for the same reason: a single remaining host cannot select itself as primary replica. In this situation, the cluster can only handle read queries.

Assigning a different host as a master if the primary master failsAssigning a different host as a master if the primary master fails

If the master host fails, MongoDB will automatically select a new master from among the available hosts.

You can influence master selection in a MongoDB cluster by configuring priorities for cluster hosts. The host with the highest priority will become a new master.

You can set the host priority using the YC CLI, API, or Terraform:

  • When creating a cluster or a host in a cluster.
  • When changing the host settings.

Minimum value (lowest priority): 0. A host with such priority value can become a master only if there are no other hosts suitable for the role. Default priority value: 1. You can specify a value higher than 100.

Was the article helpful?

Previous
Backups
Next
Sharding
© 2025 Direct Cursus Technology L.L.C.