Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scale to zero doc #356

Merged
merged 5 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/data/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export const sidebarContent: ISidebarContent = [
makePage("Volumes", "reference"),
makePage("Cron Jobs", "reference"),
makePage("Pricing", "reference"),
makePage("Scale to Zero", "reference"),
melissa-hale marked this conversation as resolved.
Show resolved Hide resolved
makePage("Usage Limits", "reference"),
makePage("Accounts", "reference"),
makePage("Teams", "reference"),
Expand Down
49 changes: 49 additions & 0 deletions src/docs/reference/scale-to-zero.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
title: Scale to Zero
---

melissa-hale marked this conversation as resolved.
Show resolved Hide resolved
Scale to Zero means reducing unnecessary costs by ensuring you only use what you need, when you need it.
melissa-hale marked this conversation as resolved.
Show resolved Hide resolved

## What is App Sleeping?

App sleeping enables automated detection of an inactive [service](/develop/services) based on outbound traffic.

Enabling App Sleep on a service tells Railway to stop the service when it is inactive, effectively reducing the overall cost to run it.
melissa-hale marked this conversation as resolved.
Show resolved Hide resolved

<Image src="https://res.cloudinary.com/railway/image/upload/v1696017787/events_gjkaob.png"
alt="App Sleeping in the Activity Feed"
layout="intrinsic"
width={700} height={460} quality={100} />

### Inactive Service Detection
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts on making "inactive" / "active" into "slept" and "wake" for consistency? This feels like it may be semantically referring to the same thing using different terms


Inactivity is based on outbound packets. If no packets are sent from the service for over 10 minutes or longer, the service is considered inactive.
melissa-hale marked this conversation as resolved.
Show resolved Hide resolved


### Reactivation
melissa-hale marked this conversation as resolved.
Show resolved Hide resolved

When the service receives traffic from the _public network*_, it is sent a signal to wake.
melissa-hale marked this conversation as resolved.
Show resolved Hide resolved

Only when the service is ready, is traffic routed to it, ensuring no requests are dropped during the startup process.

_*Currently, requests made to the service over the private network do not cause it to awake from sleep._
melissa-hale marked this conversation as resolved.
Show resolved Hide resolved

## How to enable App Sleeping

To enable App Sleeping simply toggle the feature on within the service configuration -
melissa-hale marked this conversation as resolved.
Show resolved Hide resolved

<Image src="https://res.cloudinary.com/railway/image/upload/v1696548703/docs/scale-to-zero/appSleep_ksaewp.png"
alt="Enable App Sleep"
layout="intrinsic"
width={700} height={460} quality={100} />

1. Navigate to your service's settings > Deploy > App Sleeping.
2. Toggle "Enable App Sleeping".
3. This setting will be applied across all [replicas](https://docs.railway.app/develop/services#horizontal-scaling-with-replicas) automatically.
4. When your service is put to sleep, an event will be visible in the dashboard.
5. To _disable_ App Sleeping, simply toggle the setting again.
melissa-hale marked this conversation as resolved.
Show resolved Hide resolved

## Things to Note
melissa-hale marked this conversation as resolved.
Show resolved Hide resolved
- **Latency** - There may be a small delay when requests arrive at a stopped application.
- **Private Networking** - Services that receive traffic exclusively over the private network should *not* be enabled with App Sleeping since only public network traffic will trigger the service to wake.
- **Conditions for Sleeping** - For a service to be considered inactive, it must not send outbound traffic for at least 10 minutes or more. Outbound traffic can include telemetry, NTP, etc.
melissa-hale marked this conversation as resolved.
Show resolved Hide resolved