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 look to 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 look to 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 it 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 and database configurations. Some instance types are considered “previous generation” and should 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.

Table of instance types

You can use the table 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.

As a general rule of thumb, you should always use the latest generation you can. If you are using an older version of your database engine, it is worthwhile upgrading so you can use newer generations.

PostgreSQL

PostgreSQL version Environment type Instance type Maximum allocated storage (GiB)
11.x to 12.6 Non-production db.t3.micro "500"
Production db.t3.small "10000"
12.7 to 15.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.6.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.28 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.

  2 "db.m4.4xlarge"
  3 "db.m5.large"
  1 "db.m5.xlarge"
  4 "db.m6g.large"
  3 "db.m6g.xlarge"
  2 "db.r6g.large"
 46 "db.t2.small"
  2 "db.t3.large"
  7 "db.t3.medium"
  1 "db.t3.micro"
 77 "db.t3.small"
  4 "db.t3.xlarge"
  1 "db.t4g.2xlarge"
  3 "db.t4g.large"
 15 "db.t4g.medium"
 44 "db.t4g.micro"
134 "db.t4g.small"
  1 "db.t4g.xlarge"
This page was last reviewed on 30 May 2023. It needs to be reviewed again on 30 May 2024 by the page owner #cloud-platform .
This page was set to be reviewed before 30 May 2024 by the page owner #cloud-platform. This might mean the content is out of date.