Postgres 18 just shipped, and it’s already available on Neon. Deploy it in seconds and try the new features
/Scale to zero guide

Configuring Scale to Zero for Neon computes

Learn how to configure Neon's Scale to Zero feature

Neon's Scale to Zero feature controls whether a Neon compute transitions to an idle state due to inactivity. For example, if scale to zero is enabled, your compute will transition to an idle state after it's been inactive for 5 minutes. Neon's paid plans allow you to disable scale to zero to keep your compute active. On the Scale plan, you can configure the scale to zero threshold.

important

If you disable scale to zero entirely, your compute will remain active, and you will have to manually restart your compute to pick up the latest updates to Neon's compute images. Neon typically releases compute-related updates weekly. Not all releases contain critical updates, but a weekly compute restart is recommended to ensure that you do not miss anything important. For how to restart a compute, see Restart a compute.

This guide demonstrates how to configure the scale to zero setting for a new project, for an existing project, or for an individual compute.

Scale to zero limits

Paid plans permit disabling scale to zero. On the Scale plan, you can configure the scale to zero threshold.

PlanScale to zero afterCan be disabled?
Free plan5 minutes
Launch5 minutes
ScaleConfigurable (1 minute to always on)

Enable or disable scale to zero

To enable or disable scale to zero:

  1. In the Neon Console, select Branches.
  2. Select a branch.
  3. On the Computes tab, click Edit.
  4. Enable or disable the scale to zero setting, and save your selection.

Disabling scale to zero is only supported on paid plans.

Configuring the scale to zero time

On the Scale plan, you can configure "Scale to zero after" time to increase or decrease the amount of time after which a compute scales to zero. For example, decreasing the time to 1 minute means that your compute will scale to zero faster (after the compute is inactive for 1 minute), or increasing the value to an hour means that your compute will only scale to zero after being inactive for an hour.

Initial configuration of the scale to zero time is only supported via an Update compute endpoint or Update project API call. Use the Update compute endpoint API to change the setting for an existing compute. The Update project API sets a default for all compute endpoints created in the future — it does not change the configuration of existing computes.

Update compute endpoint
Update project
# change the setting for an existing compute

curl --request PATCH \
     --url https://console.neon.tech/api/v2/projects/{project-id}/endpoints/{endpoint-id} \
     --header 'accept: application/json' \
     --header 'authorization: Bearer $NEON_API_KEY' \
     --header 'content-type: application/json' \
     --data '
{
  "endpoint": {
    "suspend_timeout_seconds": 60
  }
}
'

API parameters:

  • The suspend_timeout_seconds setting is defined in seconds
  • The default setting is 300 seconds (5 minutes)
  • The minimum setting is 60 seconds
  • The maximum setting is 604800 seconds (1 week)
  • You must supply an API key, your project ID, and the endpoint ID

After configuring a non-default value via the Neon API, you'll be able to adjust the setting via the console. Setting a non-default value makes the time selector control visible on the Edit compute modal.

Scale to zero control on the Edit compute page

Configure the scale to zero default

Configuring the scale to zero setting in your project's settings sets the project's default, which is applied to all computes created from that point forward. The scale to zero settings for existing computes are unaffected. See Change your project's default compute settings for more info about compute defaults.

To configure the scale to zero default for an existing project:

  1. Select a project in the Neon Console.
  2. On the Dashboard, select Settings.
  3. Navigate to the Compute defaults section.
  4. Select Modify defaults.
  5. Enable or disable the scale to zero setting, and save your selection.

Monitor scale to zero

You can monitor scale to zero on the Branches page in the Neon Console. A compute reports either an Active or Idle status.

Compute status

You can also view compute state transitions in the Branches widget on the Neon Dashboard.

User actions that activate an idle compute include connecting from a client such as psql, running a query on your database from the Neon SQL Editor, or accessing the compute via the Neon API.

info

The Neon API includes a Start endpoint method for the specific purpose of activating and suspending a compute.

You can try any of these methods and watch the status of your compute as it transitions from an Idle to an Active state.

Session context considerations

When a compute suspends and later restarts, the session context resets. This includes in-memory statistics, temporary tables, prepared statements, and autovacuum thresholds, among other session-specific data. If your workflow requires persistent session data, consider disabling scale to zero on a paid plan to keep your compute active continuously. On the Free plan, scale to zero is always enabled and automatically suspends your compute after 5 minutes of inactivity.

Need help?

Join our Discord Server to ask questions or see what others are doing with Neon. For paid plan support options, see Support.

Last updated on

Was this page helpful?