Feature Request: Sleep Mode API for Serverless Services
imedwei
PROOP
10 months ago
Problem Statement
Currently, Railway's serverless functionality has limitations that prevent many applications from utilizing it effectively:
- Database Connection Blockers: Applications that maintain active database connections (like Appsmith, connection poolers, etc.) cannot use serverless mode, as these connections prevent the service from sleeping.
- No True Sleep API: The
deploymentStopmutation completely stops the service, meaning:- Incoming requests cannot wake the service
- Manual intervention is required to start
- Cost Implications: Services that could benefit from reduced usage during off-hours (saving 30-50% on compute costs) are forced to run 24/7.
Proposed Solution
Implement a new deploymentSleep mutation and sleep state that:
mutation sleepDeployment($id: String!, $gracePeriodSeconds: Int) {
deploymentSleep(id: $id, gracePeriodSeconds: $gracePeriodSeconds) {
id
status # "sleeping"
}
}Expected Behavior
- Graceful Sleep Process:
- Send SIGTERM to allow graceful shutdown
- Force-close database after grace period
- Preserve deployment configuration and state
- Mark as "sleeping" not "stopped" or "crashed"
- Auto-Wake on Request:
- Incoming HTTP requests trigger automatic wake
- Brief "waking up" page while service starts
- Seamless experience once running
- Programmatic Control:
deploymentSleep- Put the service to sleepdeploymentWake- Manually wake service- Cron-compatible for scheduled sleep/wake cycles
- Status Indicators:
- Clear "sleeping" status in dashboard
- No crash notifications for intentional sleeps
- Metrics showing sleep/wake cycles and savings
Use Cases
- Business Hours Services: Internal tools used 9-5 can sleep overnight
- Development/Staging: Auto-sleep after inactivity
- Periodic Jobs: Sleep between scheduled runs
- Cost Optimization: 35-50% savings for services unused overnight/weekends
0 Threads mention this feature
0 Replies
