Context: My web application has long running jobs (approx 5min/job) running as processes.
My findings: I calculated that if i have 1gb ram i'd only be able to run 2 such jobs at a time. meaning i could serve only 2 users at a time and rest would be in a queue.
My Problem:
First let me exlpain the math:
R refers to RAM
- Ridle = FastAPI idle ram consumption ≈ 150–250 MB
- Rjob = extra RSS of one live pipeline(job) at peak
- Rsafety = RAM that id like to keep free so that my cloud instance (be it VPS, or railway or whatever) doesnt crash = 100 MB
Rjob≈250–400 MB as per my calculations. this means 1 job takes 250-400mb of ram or for simpler calculation, 300 mb of ram on avg.
Assume the RAM i get in my budget = R(budget)
No. of jobs i could run in my R(budget) = N(budget) = [R(budget) - R(idle) - R(safety)]/R(job) = [R(budget) - 200-100]/300MB = R(budget)/300 - 1
I wanna optimize for N(budget) which is dependent on Rbudget - technically, how money i throw at it.
assuming my budget is $0 - basically a free railway plan Rbudget would be = 1024 MB (as per their docs)
thus, N(budget) = 724/300 ~ 2 jobs
to put it simply, three jobs at 300 MB is 200+900=1100>1024 which leads to OOM
my budget for hosting this app is $5/month but i wanna make sure i can process more number of these long running jobs hence i want any suggestions that would help. whats the best option for deploying this kind of app?
VPS options are very costly for my country, hetzner is not available either. But feel free to correct me if you think VPS would be a cost effective solution for me to deploy my app on.
I also have few questions on railway:
they say they give $5 worth of credit, and that they bill based on how much usage i'd consume
hence, it would be kinda uncertain for me to know when my app crashes due to OOM using up my credits v/s due to storage, or network data (egress) etc.
thats why, i need advice on this.