1 Replies
22 days ago
This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.
Status changed to Open Railway • 22 days ago
22 days ago
Diagnosis: Sudden slowdown = one of four culprits: memory/CPU spike, database query bottleneck, missing index, or Railway sleeping your service.
Step 1 — Check Railway metrics immediately: Dashboard → your service → Metrics tab → look for CPU/RAM spike at the exact time it slowed.
Step 2 — Check if service is being throttled:
railway logs --tail 100
Look for: OOM, killed, memory limit, timeout, rate limit
Step 3 — If database is the culprit (most common), run:
-- Find slow queries (PostgreSQL)
SELECT query, mean_exec_time, calls
FROM pg_stat_statements
ORDER BY mean_exec_time DESC
LIMIT 10;
-- Check for missing indexes
SELECT schemaname, tablename, attname, n_distinct, correlation
FROM pg_stats
WHERE tablename = 'your_table_name';
Step 4 — Add indexes on frequently queried columns:
CREATE INDEX CONCURRENTLY idx_table_column ON your_table(column_name);
Step 5 — If Node.js/Java service, check for memory leak: Add to Railway environment variables:
NODE_OPTIONS=--max-old-space-size=512
Step 6 — Force restart the service:
railway redeploy
Step 7 — Scale up temporarily while debugging: Dashboard → Service → Settings → Resources → bump RAM to next tier.
Step 8 — Enable Railway's health check to auto-restart on hang: In railway.toml:
[deploy]
healthcheckPath = "/health"
healthcheckTimeout = 30
restartPolicyType = "on_failure"
restartPolicyMaxRetries = 3
Most likely fix order:
- Check metrics → identify spike time
- Restart service immediately
- Run slow query check on DB
- Add missing indexes
- Redeploy with health check config