Storage in Managed Service for MongoDB
Managed Service for MongoDB lets you use network and local storage drives for database clusters. Network storage drives are based on network blocks, which are virtual disks in the Yandex Cloud infrastructure. Local disks are physically located in the database host servers.
When creating a cluster, you can choose between the following storage types:
HDD network storage (
network-hdd): The cheapest option for clusters with relaxed read/write performance requirements.
SSD network storage (
network-ssd): A middle-ground solution. It's slower than local SSD storage, but unlike local disks, it ensures data integrity if Yandex Cloud hardware goes down.
Non-replicated SSD storage (
network-ssd-nonreplicated): SSD network storage with enhanced performance that is implemented by eliminating redundancy.
The storage size can only be increased in increments of 93 GB.
Local SSD storage (
local-ssd): The fastest disks.
This type of storage is only available for Intel Broadwell and Intel Cascade Lake. For a list of host classes and their respective platforms, see Host classes.
The storage size can only be increased in increments of 100 GB.
Specifics of local SSD storage
Local SSD storage doesn't provide fault tolerance for stored data and affects the overall pricing for the cluster:
- This storage doesn't provide fault tolerance for a single-host cluster: if a local disk fails, the data is permanently lost. Therefore, when creating a new Managed Service for MongoDB cluster using local storage, a 3-host fault-tolerant configuration is automatically set up.
- You are charged for a cluster with this storage type even if it's stopped. Read more in the pricing policy.
Specifics of non-replicated SSD storage
Non-replicated SSD storage doesn't provide fault tolerance for a single-host cluster: if a disk fails, the data is permanently lost. Therefore, when creating a new cluster using this storage type, a 3-host fail-safe configuration is automatically set up.
Choice of storage type during cluster creation
The number of hosts that can be created with a MongoDB cluster depends on the storage type selected:
With local SSD (
local-ssd) or non-replicated SSD (
network-ssd-nonreplicated) storage, you can create a cluster with three or more hosts (to ensure fault tolerance, a minimum of three hosts is necessary).
network-ssdstorage, you can add any number of hosts within the current quota.
Managing disk space
If at least one host in a Managed Service for MongoDB cluster runs out of its allocated disk space, the MongoDB instance on this host will crash and the host will be disabled. If the host was a
PRIMARY replica, this role will switch to one of the
SECONDARY replicas. As a result of migrating the
PRIMARY role from one host to another, you may run out of the disk space on all the hosts in the cluster, disabling the whole cluster.
To avoid this, Managed Service for MongoDB monitors disk space consumption and automatically enables read-only mode (using the
db.fsyncLock method) for hosts in the cluster that have:
- Less than 500 MB of free disk space left (if the host storage size is less than 600 GB).
- Less than 5 GB of free disk space left (if the host storage size is 600 GB or more).
After switching to read-only mode:
- Write operations will not be allowed on the host and only read operations will be possible.
- If the host was a primary replica before switching to read-only mode, this role will be automatically assigned to another cluster host, because the primary replica role requires permission to write to the disk.
If the amount of data in the cluster keeps growing, all the hosts will switch to read-only mode, one by one, and the cluster will stop accepting data to write.
Maintaining the health of a cluster
To make sure a cluster is operational when the host switches to read-only:
Increase the disk space on the host. Once there is enough space on the host, Yandex Cloud disables read-only mode automatically.
Add additional shards to the cluster. Read-only mode won't be lifted on this host, but the cluster will be able to continue working normally provided there is free disk space on the other shards.
Contact technical support and ask them to temporarily disable this host's read-only mode to manually delete a part of the data.
If you run out of free disk space completely, MongoDB will crash and the cluster will be disabled.
Force the synchronization of data between hosts. This can help when a large amount of data was deleted from the cluster, but the disk space was not released (marked as available for reuse).