Railway Credit Optimization Guide¶
To significantly reduce your Railway usage costs, follow these steps for each of your services (merp25, MZ01, MZ02, MZ03, MZ05).
1. Manually "Switch Off" Services¶
The most effective way to save credits is to Remove Deployments for services you aren't currently using.
| Service Category | Recommended Action | Risk |
|---|---|---|
| Frontend/UI Services | Remove Deployment when not in use. | None. Static files don't need to run 24/7. |
| Backend/API Services | Keep active only if other services depend on them. | Other apps may lose connectivity if the API is down. |
| Databases | NEVER remove deployments if you have live data. | Data loss or corruption if not handled correctly. |
How to Switch Off: 1. Open the service in Railway.app. 2. Click the three dots (...) on the active deployment. 3. Select "Remove Deployment". 4. To Restart: Click the "Deploy" button when you need it back.
2. Enable "Serverless" Scaling (Recommended for UI)¶
This is a "Set and Forget" optimization.
1. Go to Settings > General (or Deploy) for each service.
2. Enable "Serverless" toggle.
3. Railway will automatically "sleep" (scale to zero) the service after a period of inactivity and wake it up only when someone visits the URL.
- Frontend Wake-up: ~1-3 seconds (very fast).
- Backend Wake-up: ~10-20 seconds (depends on app initialization).
- Note: If your backend runs migrations or seeds data on startup (e.g., python startup.py), the wake-up time will be longer (30s+).
3. Set Manual Resource Limits¶
By default, Railway may allocate up to 8GB of RAM, which is very expensive.
1. Go to Settings > Resource Limits.
2. Set Memory Limit to:
- Frontends: 128MB or 256MB
- Backends: 512MB
3. Set CPU Limit to: 0.5 or 1.0.
4. Identified Services to Optimize¶
Project: merp25¶
- merp25-frontend: Safe to Switch Off / Sleep.
- merp25-backend: Keep Active (or Sleep).
Project: Zillancer (M01, M02, M03, M05)¶
- M01_travellerUI, M02_ishopUI, M03_MyinfoUI, M05_propertyUI: Safe to Switch Off when not demoing.
- M01_travellerapp, M02_ishopapp, M03_myinfoRestapi, M05_propertyapp: These are APIs. Only keep active if needed.
5. Global Safety Net¶
Go to Settings > Project Settings > Usage and set a Hard Limit (e.g., $5.00) to ensure your credit card is never charged more than you expect.