Choose a dedicated database #

View this page as Markdown

On this page

Prompt:

Move my production database onto a server of its own.

Start by confirming the application and size.

A dedicated database gives your application's production database its own PostgreSQL server in the same cell and region. The development database stays on a shared server.

You choose the database size. A move to a newly created dedicated server keeps the PostgreSQL major version of the current production database server.

A dedicated size must be supported on the platform you are using. For a billed account, it must also be opened to that account. A refused request answers database_size_not_open if either condition is unmet. The answer names the account's open sizes, says none are open, or explains that this platform serves no dedicated size. On production, billed accounts can choose Dedicated 2 GB. The larger sizes in the table are available to unbilled accounts.

What to choose #

Your database starts on a shared server. Once the production database is ready, you can move it to a dedicated server. Both server and serverless applications can make this move.

Choose a dedicated size when production needs its own database server or when the shared database's connection limit constrains the workload. Compare your memory use and peak connections with the limits of the sizes your account can use.

Size Memory CPU cores PostgreSQL server connection limit Maximum per app process
database-dedicated-2gb 2 GiB 1 50 12
database-dedicated-4gb 4 GiB 2 429 202
database-dedicated-8gb 8 GiB 2 859 417

The PostgreSQL server limit includes reserved connections. The per-process column shows the highest limit the platform can configure for that size. Ask your AI to check the current database-connection-limit with read_plan_quotas. Your deployed app reads its actual pool limit from APP_DATABASE_CONNECTION_LIMIT.

These servers have burstable CPU. After their CPU credits are spent, they run at their base CPU share. The core count is not a promise of sustained full-core performance.

Backups are kept for 35 days and are geo-redundant. The server runs in one zone. A host failure can cause a restart at any time; scheduled maintenance is Sunday, 14:00–15:00 UTC.

You can later choose another dedicated size or database-shared to move back to a shared server. Each change moves the production database and interrupts its service. If the shared server runs an older PostgreSQL major, it may refuse features your database uses.

The charge #

A dedicated database has a daily charge. The pricing page shows a monthly rate. The charge for one day is that rate divided by the number of days in that UTC month. The daily billing run is scheduled for 03:00 UTC and adds the charge for the UTC day it runs in. Review the current pricing and the charge shown on the approval page before you approve a move.

The daily server charge covers the dedicated size. Database storage is counted separately. Review the day rate on the approval page when moving to a dedicated size. Moving back to shared can still leave a dedicated charge for that UTC day.

When the target is ready, Turn Zero adds that day’s charge for the new dedicated size if it hasn’t already been recorded. It also tries to record that day’s charge for a dedicated size you’re leaving. If that second charge fails, the move can continue.

Each size is charged once per application per UTC day, even if you try that size again on the same day. If you move back to shared, the dedicated size you leave is charged for the day of the move and daily charges for that size stop while you stay on shared. Charges already made for a size you leave stay on your account.

To move to a dedicated size, your remaining free usage for the month plus available credit must exceed the charge for the remaining days. The check uses only the new size and includes today in the UTC month’s remaining days. If that day’s charge for that size and application is already recorded, the check is skipped. For an unbilled account, the charge is recorded without drawing from the account’s balance.

The move checks the new size’s charge again before it freezes production. If that charge cannot be made, the move stops before production freezes. If the charge for the size you leave cannot be made, the move can still continue. If the move fails after a charge is made, that charge stays on your account.

The dedicated charge also covers the application’s development database. At the first daily billing run after the move, the application stops counting toward the shared database charge. Shared database charges already made stay on the account.

While an account is paused, its dedicated database and data stay in place. Turn Zero still records the daily charge and writes off the amount the balance cannot cover.

What changes during the move #

The platform prepares the target server, freezes production, copies the database and switches its connection. Then it restarts the version serving production. Production is unavailable from the freeze until that restart succeeds or a revert restores the source. Preparing the server can take time before the interruption begins. There is no fixed completion time.

A production deploy or promote is refused throughout the move, including while the server is being prepared.

The application, hostname, environments, code, database and role names, and runtime setting names stay the same. The development database and stored files stay in place. Production gets a new password and host. The connection limit comes from the target's configured quota and may change.

Connections and a move back #

Temporary connections follow the same steps on shared and dedicated servers. A move ends any open temporary connection. Wait for the move to finish before requesting a fresh approval. Connect to your database.

A dedicated database uses a direct connection to PostgreSQL. There is no connection pooler on that server. Keep your application’s own pool within the limits below.

Each dedicated size has its own database-connection-limit quantity. The database role admits twice that quantity.

For a server application, both APP_DATABASE_URL and APP_DATABASE_DIRECT_URL use direct port 5432. Set each process’s pool maximum from APP_DATABASE_CONNECTION_LIMIT, which the move updates for the new size.

For a serverless application, APP_DATABASE_URL alone uses direct port 5432. Use at most one connection per function worker. The move checks that the database role can support the maximum number of function workers your account can run in that location.

For a server app outside the Unlimited plan, the move back keeps the direct address initially. A new production deploy uses pooled port 6432, and a promote uses it if the version recorded it. A serverless app gets port 6432 when the move restarts production. Server apps on the Unlimited plan keep direct port 5432.

The shared transaction pooler holds a server connection for one transaction. Before moving back, check code that relies on one server session. Features that worked through the direct address may not work through transaction pooling.

Before your AI starts #

You need a signed-in Turn Zero Cloud connection and the application you want to change. Tell your AI assistant which size you choose and when production can be interrupted. Read the approval page yourself; approving it starts the move.

Changing the size starts another copy of the database. If an earlier move left a kept copy, starting the next move removes that earlier copy first.

What your AI does #

You confirm the application and the owner's chosen size, request its browser approval, then follow that specific move until it ends. You do not pick another size or start a second move to recover from an uncertain response.

Steps #

These steps are for your AI assistant.

1. Confirm the application and size #

Use tzcloud_list_applications to identify the application and tzcloud_read_status to read its production state. Confirm that its production database is provisioned. Ask the owner to choose a size if they have not named one, and confirm the interruption is acceptable. If nobody answers, leave the database unchanged and report that choice is needed.

Check for an unfinished database move, a move of the application between cells, or a production deploy. Follow an existing move rather than requesting another. The size argument is one of the three dedicated names above, or database-shared for a move back.

2. Request approval #

Call tzcloud_set_database_size with application, the chosen size and a fresh request_id. Make this request only when the owner asks for the change. Hand the returned approval URL to the owner and wait for their decision in the browser.

A pending action means approval is needed. A decline or expiry leaves the database unchanged. Use read_approval_status to follow the decision. Its successful result confirms that the move started; it does not confirm that the database finished moving. Keep the returned move ID.

If the approval says the database has changed, check its current state. Ask for fresh approval only if the owner still wants the move.

If a response is lost, read the approval and application state before repeating anything. The same request_id returns the same pending action while it is live; after it ends, using that ID starts a new pending action.

3. Follow the move to its end #

Call tzcloud_read_status for the application with wait_seconds: 45. Read application.environments.production.database_move and match its ID to move.id in the approval outcome. Keep the pending-action ID and the move ID. An earlier completed move is not proof that this request succeeded.

Read its phase, started_at, ended_at and outcome. While outcome is null, continue reading status. The wait remains unsettled while a move is unfinished.

  • done: the database moved and production's serving version restarted. The version history shows a restart row.
  • reverted: the move did not complete; the source remains or has been restored. Report this result to the owner before considering another attempt.

The ended move stays in status until the next move starts. If status does not establish an outcome, report what you can read and keep following it. Do not infer success from approval or repeat the change merely because it took longer than expected.

4. Check the application #

After done, use an existing read-only application check to confirm that production serves and can read its data. For a server, confirm that the application’s pool reads the injected connection limit. For a function, verify that the deployed function can read the database. Report the chosen size and the final move outcome; do not create or change production records just to test the move.

Expected result #

The matching production move has an ended_at and outcome: done. Your application serves from the new database and its development database is unchanged. A server’s pool uses APP_DATABASE_CONNECTION_LIMIT. A deployed function uses APP_DATABASE_URL for its connection.

Use tzcloud_read_status with database_reading: true to see the dedicated server’s recorded disk size and the bytes its databases hold. The reading also shows the database role’s current connections by state and its connection limit, if it has one.

Refusals #

Code Cause Remedy
database_size_not_open This platform serves no dedicated size, or the requested size is not open to this billed account. Read the sizes the answer names, or its statement that none are open. Report it to the owner; do not substitute a size.
database_move_in_flight A move is unfinished, or an earlier move has ended but its work is still stopping. Follow the move to its end. If its work is still stopping, repeat in a minute. The platform also refuses a production deploy or promote until the move ends.
cell_move_in_flight The application is moving to another cell. Wait for that move to finish before requesting a database size change.
account_paused The account is paused. Wait for the scheduled reset in the response. For a move back to shared during the pause, contact support.
deploy_in_flight A production version is still in flight, whether it is a deploy, promote, rollback or restart. Use read_status or list_versions to follow that version to its end before asking for the move again.
balance_short The balance is at or below the chosen size’s charge for the days left in the UTC month, including today. Read the answer's charge and balance explanation with the owner before another request.
dedicated_capacity The cell, region or concurrent-move bound is full. Report the capacity bound named in the answer.
dedicated_size_below_workers The database role allows fewer connections than the maximum number of function workers your account can run in that location. Production stays at its current size. Ask the owner to choose an available dedicated size whose role limit covers the worker limit in the refusal. Wait for their choice before requesting another move.
database_size_unread The platform could not measure the database against its move-size limit. Retry in a few minutes.
database_too_large_to_move The database is above the limit for this request. Contact support to arrange a move.
invalid_request The size is outside the four allowed values, or production already has that size. Check the requested size and whether production already uses it.

This table covers common refusals. Read the action reference for the full contract and Refusals for the returned refusal.