View a markdown version of this page

Capacity - AWS Amplify

Capacity

The Amplify backend database runs on serverless PostgreSQL. You don’t choose a server or instance size. You set a maximum capacity for each environment in backend capacity units (BCUs), from 1 BCU up to your plan’s limit: 1 BCU on Basic, 4 on Pro and 16 on Pro Plus, and AWS Amplify scales the database up to that maximum. For each plan’s limit, see Pricing and spend limits.

How capacity works

Amplify changes the database’s capacity with your app’s traffic:

  • Scaling – Amplify adds capacity as load grows and releases it as load falls. A new backend starts with a maximum of 1 BCU.

  • Idle – After your app has had no traffic for 5 minutes, the backend goes to sleep, and the next request wakes it in seconds. You’re not charged for compute while it’s asleep. Going to sleep isn’t a pause. For more information about pauses, see When Amplify pauses a backend.

Set the maximum capacity

You can set the maximum in three places. A deployment uses the first one that sets it, in this order:

  1. The environment’s env.<env>.backend.database block in amplify.jsonc.

  2. The root backend.database block in amplify.jsonc.

  3. The value that aws amplifygen3 env edit --max-backend-capacity-units stored.

If none of them sets it, the database keeps its current maximum.

To set the maximum for every environment, add maxBackendCapacityUnits to the database block in the backend block of amplify.jsonc:

"backend": { "database": { // From 1 up to your plan's limit "maxBackendCapacityUnits": 4 } }

To set it for one environment, put the same database block in env.<env>.backend:

"env": { "production": { "backend": { "database": { "maxBackendCapacityUnits": 8 } } } }

To set it with the CLI instead, run the following command for an environment such as production:

aws amplifygen3 env edit --env production --max-backend-capacity-units 4

The next deployment to the environment applies the value. To see the applied value, run aws amplifygen3 env get --env production.

env edit returns an error for a value over your plan’s limit. A deployment with a value over the limit fails with CONFIG_RETRIEVAL_FAILED. If you move to a smaller plan, lower or remove each value over the new limit before you deploy again.

What happens when you change it

A deployment that changes the maximum waits for the database to apply the new value, then applies migrations and builds your website. The change can restart the database. The data API returns 503 with a Retry-After header while the database restarts. The client SDK sends the request again after that time. For more information about the error codes, see Data API errors.

See how much capacity you use

aws amplifygen3 app get --app my-app shows BCU-hours this month and Last used for all of the backend’s branches, under Database usage. Replace my-app with the name of your app. The count starts again from 0 on the first of each month (UTC). For one branch’s share, run aws amplifygen3 branch get --name <branch> --env <env>.

When Amplify pauses a backend

Amplify pauses a backend in the following cases:

  • On the free plan, none of the backend’s branches has been used for 7 days.

  • On the free plan, the backend has used up its monthly BCU-hours.

  • On any plan, a branch’s database has reached the plan’s storage limit.

For each plan’s limits, see Pricing and spend limits.

Amplify pauses every branch of the backend, even when only one branch caused the pause. A paused backend keeps its data. It serves no requests, and a request doesn’t resume it. A deployment to a paused backend stops at once. You can’t pause a backend yourself.

Resume a paused backend

Run the following command to resume the backend. Replace my-app with the name of your app.

aws amplifygen3 backend resume --app my-app

The command returns right away, and the resume continues in the background. When it’s done, aws amplifygen3 app get --app my-app shows the backend as READY. Until then, the aws amplifygen3 db commands can’t connect.

Amplify refuses the resume while a branch is over its storage limit, or while the free plan’s BCU-hours are used up:

  • To resume a backend over its storage limit, delete the branch, or move to a plan with a storage limit that the branch fits in.

  • To resume a backend that used up its BCU-hours, move to a larger plan, or wait for the count to reset on the first of the month (UTC) and run backend resume again.