Horizontal Scaling on Railway

Avatar of wyzllewyzlle
·

Horizontal scaling describes the process of adding additional instances of your app to the infrastructure. It increases your app's resiliency, availability, and can help you scale to high demand. Whilst Railway doesn't offer first-party support, we have a workaround for now that allows you to scale your app to any number of instances. It also supports auto-scaling, where your app scales up under periods of high load, before scaling back down once the traffic calms down.

Step-by-step guide

  1. Open your project, press Cmd/Ctrl + K & type in horizontal-scaler
  2. Fill in the required configuration options. BACKBOARD_TOKEN can be found in the CLI’s configuration file $HOME/.railway/config.json.
  1. That’s it! Now your service will be automatically scaled out based on it’s resource usage.

Configuration Options

  1. BACKBOARD_TOKEN - This can be found in $HOME/.railway/config.json. Make sure you have installed and are logged into CLI.
  2. SERVICE_NAME - Name of the service that you want to horizontally scale.
  3. CPU_MIN - If your averaged vCPU usage is below this, services will scale down.
  4. CPU_MAX - If your averaged vCPU usage is above this, services will scale out.
  5. MEMORY_MIN - If your averaged memory usage is below this, services will scale down.
  6. MEMORY_MAX - If your averaged memory usage is above this, services will scale out.
  7. SERVICE_MIN - Minimum number of instances that should be load-balanced at any given time, irrespective of the resource usage.
  8. SERVICE_MAX - Maximum number of instances that should be load-balanced at any given time, irrespective of the resource usage.

Conclusion

We hope this post was helpful to you if you were looking for a way of automatically scaling out your services on Railway. If you encounter any issues / have any questions about using the horizontal-scaler, please reach out to us in our Discord server. If you would like to see first-party horizontal scaling directly inside of Railway, please upvote this canny post.