RailwayDocs

Cost Control

Railway 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

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

Custom email alert

You can think of this as a soft limit. When your resource usage reaches the specified amount, we will email you that this threshold has been met. 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

Resource limits

Resource limits allow you to limit the maximum amount of CPU and memory available to a service.

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

Resource Limits setting

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

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_URL environment variable, instead of DATABASE_PUBLIC_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 serverless

Enabling Serverless on a service tells Railway 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.