Essay - Published: 2024.09.27 | cloud | create | hosting | railway | serverless-containers | tech |
DISCLOSURE: If you buy through affiliate links, I may earn a small commission. (disclosures)
I build a lot of projects but a majority of them get very little traffic. This means that keeping them online all the time is wasteful as they aren't needed - just burning a hole in my pocket.
In this post we'll explore how to make serverless containers hosted on Railway (referral) scale to zero so you don't pay for them when they're not being used.
Railway calls it's scale-to-zero feature "App Sleeping". (official Railway Docs)
How it works:
When an app is asleep you only pay for its storage (for the image, for any persistent stores) not its compute (cause it's not computing anything).
Caveats with App Sleeping:
For my workloads this makes a lot of sense cause none of my apps are critical so slow wake up times / possibility of not waking up is okay for me.
To setup App Sleeping:
App SleepingEnable App SleepingI've been using Railway for the past few months and been pretty happy with it - I'm currently hosting 5 apps there. It's pretty simple and not the cheapest but it makes a lot of my hosting scenarios much simpler so that's a win for me.
For hosting I prefer serverless containers because it allows me to build the same container locally in dev that I deploy in prod. I use CloudSeed (my F# project boilerplate) to give me a headstart - it includes a containerized fullstack F# app ready for deployment.
If you liked this post you might also like:
The best way to support my work is to like / comment / share for the algorithm and subscribe for future updates.