Treasury|Treasury Docs

Cost Control

Treasury provides controls over resource usage in the form of usage limits, resource limits, private networking, and serverless auto-sleeping of inactive services.

Usage limits

Usage Limits allow you to set a maximum limit on your usage for a billing cycle. If your resource usage for the billing cycle exceeds the limit you configured, we will shut down your workloads to prevent them from incurring further resource usage.

Configuring usage limits

Usage Limits Modal

Use your Treasury workspace controls to set usage limits. Once you click the Set Usage Limits button, you will see a modal where you can set a Custom alert and a Hard limit for tracked usage.

Usage limit types

Usage limit controls depend on the services enabled for your workspace:

  • Compute usage covers CPU, memory, storage, and network egress for your services.
  • AI-agent usage is not currently documented as a public Treasury billing product. See Treasury Agent for the current status.

Hitting a hard limit can take workloads offline to prevent additional usage. Review limit changes before applying them in production workspaces.

Custom alert

You can think of this as a soft limit. When your resource usage reaches the specified amount, Treasury can notify the workspace according to the alert channels configured for the account. Your resources will remain unaffected.

Hard limit

Once your resource usage hits the specified hard limit, all your workloads will be taken offline to prevent them from incurring further resource usage. Think of the hard limit as the absolute maximum amount you're willing to spend on your infrastructure.

We will send you multiple reminders as your usage approaches your hard limit:

  1. When your usage reaches 75% of your hard limit
  2. When your usage reaches 90% of your hard limit
  3. When your usage reaches 100% of your hard limit and workloads have been taken down.

Usage limits FAQ

Replica limits

Replica limits allow you to limit the maximum amount of CPU and memory available to each replica.

To configure replica limits, navigate to your service's settings > Deploy > Replica Limits.

Resource Limits setting

Using replica limits makes sense in scenarios where:

  1. You don't want to risk a high bill due to unexpected spikes in usage
  2. You are okay with the service crashing if it exceeds the limit

Use private networking

Using Private Networking when communicating with other services (such as databases) within your Treasury project will help you avoid unnecessary Network Egress costs.

With databases

Communicate with your Treasury database over private networking by using the DATABASE_URL environment variable, instead of DATABASE_PUBLIC_URL.

With other services

If your Treasury services need to communicate with each other, you can find the service's private URL in the service settings:

Private Network URL

Learn more about Treasury's Private Networking here.

Enabling serverless

Enabling Serverless on a service tells Treasury to stop a service when it is inactive, effectively reducing the overall cost to run it.

To enable Serverless, toggle the feature on within the service configuration pane in your project:

Enable App Sleep
  1. Navigate to your service's settings > Deploy > Serverless
  2. Toggle "Enable Serverless"
  3. To disable Serverless, toggle the setting again

Read more about how Serverless works in the Serverless page.