Skip to main content

Creating a relational database

To create a relational database using PostgreSQL, MariaDB, or MySQL in the Cloud Platform, follow the example guidance in the module or use the Cloud Platform CLI.

Choosing an appropriate database configuration

Non-production

If you’re creating a database in a non-production environment, you should turn off your database outside of work hours.

The Cloud Platform provides a way to do this in the relational database module, which will temporarily stop your database at 10PM and restart it at 6AM UTC (11PM and 7AM BST).

To enable this, add the enable_rds_auto_start_stop attribute to your database configuration:

module "rds" {
  ...
  enable_rds_auto_start_stop = true
  ...
}

Production

If you’re creating a database in a production environment, you should turn on deletion protection. To do this, update your database configuration:

module "rds" {
  ...
  deletion_protection = true
  ...
}

This will stop the database from being able to be deleted without a second step.

If you want to delete your database, raise a PR to set deletion_protection to false (step one), and then raise another PR to remove your database (step two).

Choosing an appropriate instance type

Amazon RDS (which manages your database) supports a wide range of instance types. Some instance types are considered “previous generation” and must not be used.

Instance types are named based on their family/purpose, generation, any additional capabilities, and size.

For Amazon RDS, instance types will always be prefixed with db.

You can read the supported DB engines for DB instance classes for more information.

Table of instance types

You can use the tables below to pick an appropriate instance type for your corresponding database engine and engine version. This instance type should be suitable for most applications, environments, and how users of the Cloud Platform generally use Amazon RDS.

You should always use the latest instance type you can. If you are using an older version of your database engine, you should upgrade your database engine version so you can use newer instance types.

PostgreSQL

PostgreSQL version Environment type Instance type Maximum allocated storage (GiB)
12.7 to 16.x Non-production db.t4g.micro "500"
Production db.t4g.small "10000"

MariaDB

MariaDB version Environment type Instance type Maximum allocated storage (GiB)
10.4.x to 10.11.x Non-production db.t4g.micro "500"
Production db.t4g.small "10000"

MySQL

MySQL version Environment type Instance type Maximum allocated storage (GiB)
8.0.25 to 8.0.x Non-production db.t4g.micro "500"
Production db.t4g.small "10000"

If you find your Amazon RDS database is running out of CPU or memory, try changing the instance type (micro, small) to a larger instance type such as medium.

If you find your Amazon RDS database is running out of storage, try changing your maximum allocated storage to a larger size. micro instance sizes are limited to a maximum of 6,114 GiB and small instance sizes are limited to a maximum of 16,384 GiB.

Statistics

At the time of writing, the following instance types were in use (along with how many) on the Cloud Platform. This can be useful to help you rightsize your instance type compared to other users of the Cloud Platform.

  3 "db.m5.large"
  1 "db.m5.xlarge"
  1 "db.m6g.2xlarge"
  4 "db.m6g.large"
  3 "db.m6g.xlarge"
  2 "db.r6g.large"
 10 "db.serverless"
  6 "db.t3.medium"
  1 "db.t3.micro"
 37 "db.t3.small"
  2 "db.t3.xlarge"
  3 "db.t4g.2xlarge"
  7 "db.t4g.large"
 14 "db.t4g.medium"
128 "db.t4g.micro"
184 "db.t4g.small"
  3 "db.t4g.xlarge"
This page was last reviewed on 27 December 2023. It needs to be reviewed again on 27 December 2024 by the page owner #cloud-platform .
This page was set to be reviewed before 27 December 2024 by the page owner #cloud-platform. This might mean the content is out of date.