Skip to content

Service Architecture

This page describes what an Exoscale Managed PostgreSQL service is made of: its nodes, the endpoints it exposes, the role and databases it starts with, and the IP filter that decides who can reach it.

Nodes

A service runs on one, two or three nodes, set by the plan: one for hobbyist-* and startup-* plans, two for business-*, three for premium-*. The extra nodes are standbys, see High availability.

Read the plan, node count, CPU, memory and disk of a service:

exo api get-dbaas-service-pg SERVICE_NAME -z ZONE \
  -q '{plan: plan, nodes: "node-count", cpu: "node-cpu-count", ram: "node-memory", disk: "disk-size"}'

Parameters:

  • SERVICE_NAME: name of the service, for example my-postgresql.
  • ZONE: zone of the service, for example ch-gva-2.

Memory and disk are in bytes. All the nodes of a service run in the zone it was created in. A copy of the data in another zone is a separate service: a read replica or a fork.

The pg and pgbouncer Components

Every service exposes two endpoints, called components, on the same hostname with two ports:

  • pg: the PostgreSQL server. This is the endpoint in the service URI.
  • pgbouncer: the PgBouncer connection pooler, running next to PostgreSQL.

List them:

exo api get-dbaas-service-pg SERVICE_NAME -z ZONE -q 'components'

Each entry has a component, a host, a port, a route and a usage (primary or replica).

Read the ports from this command or from the service URI rather than copying them from an example: they are assigned by the platform.

On the pg port, the database name in the connection string is a database. On the pgbouncer port, it is the name of a connection pool.

TLS Is Required

The service URI carries sslmode=require, and a connection with sslmode=disable is refused. require encrypts the connection but does not check the server’s identity. To check it, download the CA certificate and use sslmode=verify-full:

exo dbaas ca-certificate -z ZONE > exoscale-dbaas-ca.pem

Then add sslmode=verify-full&sslrootcert=exoscale-dbaas-ca.pem to the connection URI. See Connect with psql.

The avnadmin Role

A new service has one administrator role for you, avnadmin. It owns defaultdb and is the user of the service URI. avnadmin is not a PostgreSQL superuser:

SELECT rolname, rolsuper, rolcreaterole, rolcreatedb, rolreplication, rolbypassrls
FROM pg_roles
WHERE rolname = current_user;
 rolname  | rolsuper | rolcreaterole | rolcreatedb | rolreplication | rolbypassrls
----------+----------+---------------+-------------+----------------+--------------
 avnadmin | f        | t             | t           | t              | t

avnadmin can create databases, roles and objects, grant privileges, bypass row-level security and open replication connections. It is a member of pg_read_all_stats and pg_signal_backend, so it can read the statistics of every session and cancel or terminate them. It is not a member of pg_monitor.

What avnadmin cannot do, and what to use instead:

RefusedUse instead
ALTER SYSTEMService settings, see Configure PostgreSQL settings
COPY ... TO PROGRAM / FROM PROGRAM, pg_read_file()Client-side \copy
CREATE TABLESPACE (only pg_default and pg_global exist)The service disk
Some extensionsSee Manage extensions

The roles whose names start with _aiven or _avnadmin, and postgres, belong to the platform.

Databases That Already Exist

DatabaseOwnerPurpose
defaultdbavnadminYours. Encoding UTF8, collation en_US.UTF-8.
_aivenpostgresInternal to the platform.

Caution

Do not write to, rename or drop _aiven. The platform uses it to run the service.

In defaultdb, the public schema is owned by pg_database_owner and only plpgsql is installed. The other extensions are created on demand. Create one database per application rather than sharing defaultdb:

exo dbaas database create SERVICE_NAME DATABASE_NAME -z ZONE

Parameters:

  • DATABASE_NAME: the name of the database to create.

The IP Filter

The service has a public endpoint, and the IP filter is the list of CIDR blocks allowed to connect to it. It applies to both the pg and the pgbouncer ports. A connection from an address outside the list times out.

exo dbaas update SERVICE_NAME -z ZONE -f --pg-ip-filter 203.0.113.0/24,198.51.100.7/32

Warning

The list you set replaces the previous one. Always pass every block you want to keep.

An empty filter blocks every connection. That is the state of a fork or a read replica created without an IP filter. See Restrict connections.

Related Pages

Last updated on