Sub topic 11
Tuning with parameter groups
This chapter assumes you can provision an RDS instance, as covered earlier, and that you know what a database configuration file does. You should be comfortable with the AWS CLI.
What a parameter group is
On a self-managed server you edit a file such as postgresql.conf. RDS gives you no shell access to the host, so it exposes engine settings through a parameter group. A parameter group is a named set of engine settings that you attach to one or more DB instances.
Every instance has one. If you do not choose one, RDS attaches a default group. You cannot edit a default group. To change any setting, create a custom group and attach it to the instance.
A group belongs to a family, such as postgres16. The family ties the group to an engine and major version. You cannot attach a postgres16 group to a PostgreSQL 15 instance.
Create a group and change a setting
The following commands create a custom group and set log_min_duration_statement to 500. PostgreSQL then logs every statement that runs longer than 500 ms.
aws rds create-db-parameter-group \
--db-parameter-group-name demo-pg16 \
--db-parameter-group-family postgres16 \
--description "Custom parameters for demo-pg"
aws rds modify-db-parameter-group \
--db-parameter-group-name demo-pg16 \
--parameters "ParameterName=log_min_duration_statement,ParameterValue=500,ApplyMethod=immediate"Creating the group does not change your database. You must also attach it to the instance:
aws rds modify-db-instance \
--db-instance-identifier demo-pg \
--db-parameter-group-name demo-pg16 \
--apply-immediatelyDynamic and static parameters
Each parameter is either dynamic or static. This decides when a change takes effect.
| Type | When it applies | Allowed `ApplyMethod` |
|---|---|---|
| Dynamic | Immediately, with no restart | `immediate` or `pending-reboot` |
| Static | After the instance reboots | `pending-reboot` only |
log_min_duration_statement is dynamic, so immediate works. Parameters such as shared_preload_libraries in PostgreSQL are static. If you request immediate for a static parameter, the API returns an error.
Check that a change applied
After a modification, look at the instance's parameter group status:
aws rds describe-db-instances \
--db-instance-identifier demo-pg \
--query "DBInstances[0].DBParameterGroups"The ParameterApplyStatus field reads in-sync when the instance matches the group. It reads pending-reboot when a static change is waiting for a restart.
Common errors
- Editing the default group. RDS rejects this. Create a custom group first.
- Wrong family. A group for
postgres16will not attach to a different major version. Create a new group when you upgrade. - Forgetting the reboot. A static change stays pending until you reboot. Plan it for a maintenance window, because a reboot interrupts connections.
- Sharing a group by accident. One group can serve many instances. A change to it reaches all of them. Use a separate group for each environment, such as test and production.
- Invalid values. Some parameters accept formulas or units that differ from the engine's own syntax. Check the parameter's allowed values with
describe-db-parametersbefore you set it.
Exercise
You set the static parameter shared_preload_libraries in a custom group that is already attached to a running instance. The instance still shows the old value an hour later. What is the likely cause, and what do you do?
Show answer
Static parameters apply only after a reboot, so the instance reports pending-reboot in ParameterApplyStatus. Reboot the instance, ideally in a maintenance window, and the new value takes effect.