Database Configuration
On Zenifra, the main database settings are related to version, instances, password, failover, and storage.
PostgreSQL vs MariaDB
| Characteristic | PostgreSQL | MariaDB |
|---|---|---|
| Available versions | 15, 16, 17, 18 | 10, 11 |
| Instances | 1 to 6 total instances (db-free: 1) | 3 fixed instances |
| Instance changes later | Yes, in hourly billing | No |
| Automatic failover | Yes, with 2 to 6 instances | Yes |
| Write to 2 instances | Optional, no restart, adjustable per transaction | Optional; changing it restarts one instance at a time |
db-free plan (legacy) | Yes | No |
Database version
At creation time, the user can choose any version available in the console.
During edit:
- only forward upgrades are supported, to a version offered by the database plan: PostgreSQL 16, 17, or 18; MariaDB 11
- downgrades are not supported
- requesting the current version changes nothing and returns an error
- the database must be running, with no other operation in progress
Through the API, use PATCH /v1/project/:id/database/version; see the error codes in Databases — API.
Warning: version upgrades can cause a few minutes of downtime. Do this during low-traffic hours.
Instances and replicas
PostgreSQL
- minimum of 1 total instance
- maximum of 6 total instances
- the primary instance handles writes and reads
- extra instances act as read replicas
In hourly billing, the total instance count can be increased or decreased later while the database is running. In monthly and yearly billing, the configuration is fixed in the contract. On the db-free plan, the database always uses 1 instance.
MariaDB
MariaDB always runs with 3 fixed instances. That quantity cannot be changed.
Password
The database password can be renewed after creation, while the database is running. Zenifra generates a completely new password, which the console shows only once; store it somewhere safe. The database may be unavailable during the process. If the renewal fails, the previous password is restored. Until the renewal finishes, stopping the database, changing the plan, and changing instances or storage are blocked.
Applications that use the database are not updated automatically. The console lists the linked applications, both those created with the database from a template and those linked by an internal connection, so you can manually update the connection variable (for example, DATABASE_URL) in each one.
Connection details
The console shows:
- host (
postgresql-<project-id>.managed.zenifra.comormariadb-<project-id>.managed.zenifra.com) - port
- username
app - database name
app - a ready-to-copy connection URI, always with TLS (
sslmode=requirefor PostgreSQL andssl=true&sslmode=requirefor MariaDB) - on MariaDB, the Driver selector, with the ready-made string for your driver (see Connect your application to the database)
The password is shown only at creation or after a renewal; afterward, the URI is shown with a masked password.
For PostgreSQL with 2 to 6 instances, the console also shows a read-only URI that routes queries to the replicas. For MariaDB, the provided connection points to the primary instance.
Public access
The host and port above are public by default and accept TLS connections. In the Public access card on the database edit page, you can turn that access off: the public address stops accepting connections and the database is reachable only through private connections between applications or from inside the platform. While access is off, the connection card shows the Public access off notice.
When you turn it back on, the database answers again on the same host and port, and the external URI does not change. Password rotation and private connections work in both states. The change requires the database to be running and the database.exposure.update permission. See the details in Database.
TLS
TLS encrypts everything between your application and the database: password, queries, and data. We recommend keeping it on.
- PostgreSQL: requires TLS by default. At creation, use the Require TLS (encrypted connection) switch; later, the Require TLS switch in the TLS card of the database edit page. When it is off, the database also accepts unencrypted connections, and the Console strings still use TLS. Turning it off asks for confirmation, and you can turn it back on at any time. The change requires the database to be running and the
database.exposure.updatepermission. - MariaDB: always requires TLS, with no option to turn it off.
Connections without TLS travel in the clear over the internet. Turn it off only if your application cannot use TLS. See Require TLS on PostgreSQL.
Write to 2 instances
By default, the primary instance confirms each write without waiting for the replicas. It is the fastest mode. With the Write to 2 instances option on, each write is only confirmed after a replica has also received it: it is a little slower and, while a replica is available, a primary failure does not lose a committed write.
Turn it on in the Write to 2 instances card, on the database edit page, or through the API, with PATCH /v1/project/:id/database/synchronous-writes. The change requires the database to be running and the database.exposure.update permission.
| PostgreSQL | MariaDB | |
|---|---|---|
| Default | Off | Off |
| On | Every COMMIT waits for a replica to confirm | Every COMMIT waits for a replica to confirm |
| When changed | Applies to the next transactions, without restarting the database | The database restarts one instance at a time, and open connections may drop for a few seconds |
| Per transaction | SET LOCAL synchronous_commit = on asks for the guarantee with the option off; SET LOCAL synchronous_commit = local skips it with the option on | Not available |
| No replica responding | If no replica is available, writes continue on the primary only, without blocking the application | If the replica does not respond within 10 seconds, writes continue on the primary only |
| Instances | Applies with 2 or more; with 1 instance, it has no effect | Always applies (3 instances) |
The cost is the round trip to the replica in each transaction that waits. Reads do not change. See the per-transaction example in How Zenifra PostgreSQL works.
Failover
Automatic failover is supported for PostgreSQL with 2 to 6 instances and for MariaDB.
In case of primary instance failure, the platform can promote a replica automatically. Open connections can be closed during the switch; configure the application to reconnect. To keep committed writes through the switch, turn on Write to 2 instances.
Backups
Databases have automatic backups included in the plan, with 3 to 30 days of retention, and restores are done by support. See Automatic backups. Also keep your own exports (pg_dump or mariadb-dump/mysqldump) of critical data as an extra layer. Test restores periodically.
Storage
- every database uses persistent storage
- storage can increase
- storage can never shrink
- changes are only available in hourly billing; on monthly and yearly contracts, capacity is fixed for the contract term
- on the
db-freeplan, storage is fixed at 1 GB - increasing storage may cause temporary downtime
Good practices
- Plan version upgrades during low-traffic windows.
- Plan storage increases and instance adjustments considering possible temporary downtime.
- Manually configure
DATABASE_URLin the HTTP application; Zenifra does not inject this ENV automatically. - If no client outside Zenifra uses the database, turn public access off and connect your applications through private connections.
- Turn on Write to 2 instances when no committed write can be lost, as with payments and orders. On PostgreSQL, if only some transactions need it, keep the option off and use
SET LOCAL synchronous_commit = onin them. On MariaDB, change the option during low-traffic hours.
Last updated on
How Zenifra Valkey works
Zenifra managed Valkey inside out: Key-Value, Cache and Queues profiles, memory per plan, AOF, replicas on larger plans, eviction on Cache and TLS always.
Database Plans
Zenifra database plans, from db-starter to db-enterprise: vCPU, RAM and price per instance, PostgreSQL connections, metrics, instances, storage and contracts.