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 together 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 utilization 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. There are two thresholds:
- First threshold upon which the storage will be increased during the next maintenance window.
- Second threshold upon which the process of increasing the storage size will start right away.
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.
As soon as one of the specified conditions is met, the storage size will be increased:
- For network HDDs and SSDs, by the higher value of the two: 20 GB or 20% of the current disk size.
- For non-replicated SSDs, by 93 GB.
- For local SSDs:
- In an Intel Broadwell or Intel Cascade Lake cluster, by 100 GB.
- In an Intel Ice Lake cluster, by 368 GB.
The storage size will be automatically increased on repeated triggers until it reaches the specified maximum. After that, you can specify a new maximum storage size manually.
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.