Storage in Managed Service for PostgreSQL
Managed Service for PostgreSQL allows you to 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 select the following disk types for data storage:
-
Network HDD storage (
network-hdd
): Most cost-effective option for clusters that do not require high read/write performance. -
Network SSD storage (
network-ssd
): Balanced solution. Such disks are slower than local SSD storage, but, unlike local disks, they ensure data integrity in case Yandex Cloud hardware goes down. -
Non-replicated SSD storage (
network-ssd-nonreplicated
): Network SSD storage with enhanced performance but without redundancy.The storage size can only be increased in 93 GB increments.
-
Local SSDs (
local-ssd
): Disks with the fastest performance.The size of such storage can be increased:
- For Intel Broadwell and Intel Cascade Lake: In 100 GB increments only.
- For Intel Ice Lake: In 368 GB increments only.
Note
For clusters with hosts residing in the
ru-central1-d
availability zone, local SSD storage is not available if using the Intel Cascade Lake platform.
Selecting disk type during cluster creation
The number of hosts you can create along with a PostgreSQL cluster depends on the selected disk type:
-
With local SSD (
local-ssd
) or non-replicated SSD (network-ssd-nonreplicated
) storage, you can create a cluster with three or more hosts.This cluster will be fault-tolerant.
Local SSD storage impacts the cost of a cluster: you are charged for it even if it is not running. For more information, see Pricing policy.
-
With network HDD (
network-hdd
) or network SSD (network-ssd
) storage, you can add any number of hosts within the current quota.
For more information about limits on the number of hosts per cluster, see Quotas and limits.
Managing disk space
When the storage is more than 97% full, the host automatically switches to read-only mode, while all DBs get DEFAULT_TRANSACTION_READ_ONLY
set to TRUE
through the ALTER DATABASE
query.
In this mode, the INSERT
, DELETE
, or UPDATE
queries result in an error.
You can monitor storage usage on cluster hosts by setting up alerts in Yandex Monitoring:
Recovering a cluster from read-only mode
Use one of these methods:
-
Increase the storage capacity so that it exceeds the threshold value. Managed Service for PostgreSQL will then disable read-only mode automatically.
-
Disable read-only mode manually and free up storage space by deleting some data.
Alert
When doing so, make sure the amount of free disk space never reaches zero. Otherwise, since the fail-safe is disabled, PostgreSQL will crash and the cluster will stop working.
Automatic increase of storage size
The storage size auto increase feature allows avoiding its overflow and switch of hosts to read-only mode.
Storage size is increased upon reaching a preset threshold that is specified as a percentage of the total storage size. Two thresholds are used:
- First threshold on reaching which storage size will be increased during the next maintenance window.
- Second threshold on reaching which the process of increasing storage size will start immediately.
If both thresholds are set, make sure the second one is higher than the first one.
While increasing storage size, host clusters will be unavailable.
Storage size will be increased to the value set in the respective setting. After the threshold is reached for the first time, the feature will be disabled: if the threshold values are exceeded again, storage size will not be increased. To reactivate the feature, set a new storage size value after the threshold is reached.
You can set up automatic increase of storage size:
If you have set up the storage size to increase within the maintenance window, set up a schedule for the maintenance window.