Optimize Usage

Railway provides controls over resource usage in the form of usage limits and auto-sleeping of inactive services.

Configuring Usage Limits

Usage Limits allow you to set a maximum limit on your usage for a billing cycle.

Visit the Account Usage page to set the usage limits. Once you click the Set Usage Limits button, you will see a modal above where you can set a Custom email alert and a Hard limit.

Usage Limits Modal

Setting Limits for Teams

If you want to set a usage limit for your team, use the account switcher in the top left corner of your dashboard to access the team's usage page.

Custom email alert

Configure a soft limit by setting a threshold in Custom email alert. When your resource usage reaches the specified amount, we will email you that this threshold has been met and resources continue running.

Hard limit

Configure a hard limit to take resources offline once usage meets the specified threshold.

Multiple emails will be sent 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.

Find more information about Usage Limits in the reference page.

Use Private Networking

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

With databases

Communicate with your Railway database over private networking by using the DATABASE_PRIVATE_URL environment variable, instead of DATABASE_PUBLIC_URL:

Database Private URL

With other services

If your Railway 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 Railway's Private Networking here.

Enabling App Sleeping

Enabling App Sleep on a service tells Railway to stop a service when it is inactive, effectively reducing the overall cost to run it.

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

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

Read more about how App Sleeping works in the App Sleeping Reference page.

Resource Limits

Resource limits are a way to limit the maximum amount of resources available to a service.

To toggle resource limits, navigate to your service's settings > Deploy > Resource Limits.

Resource Limits setting

Use Resource Limits

Using resource 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

Edit this file on GitHub