2 years ago
I have a use-case in my project where I have to deploy a new instance of a service (based on a Docker image) that should be spawn individually for each of the user of my webapp.
Estimated usage would be around 300 to 500 services in total per month.
I'm planning to use Railway public API to programmatically create/deploy a new service for each active subscribers.
Each of those services will use exactly the same base Docker image, except different values in their build arguments.
Depending on the user's active subscription status at the end of their billing period, the service should either be kept active, or be shut down.
Is this kind of use-case feasible to be done on Railway?
How's your experience so far in this matter?
Would be great if someone can share their experience.
Thank you very much!
22 Replies
Thank you so much for the insights @Attacler/Bart.
Yes, that’s exactly what I wanted to achieve: to be able to create/delete services on the fly. As for the build command/variable, there is a public API endpoint to upsert env variable for each services.
So I think the flow would be:
create an endpoint in my webapp that listen to a Stripe webhook that Stripe will call whenever the user subscribe/unsubscribe to the service
when such request is received by my webapp, my webapp would call Railway’s GraphQL API to:
a. Create a service
b. Upsert the variables depending on the user’s subscription plan and preferences
c. Deploy the serviceupon unsubscription, call the Railway’s GraphQL endpoint to destroy/delete the service
——
One other question: is there a template/tool to manage all running services? (A web-based simple sortable/filterable table in a dashboard page would do)
I can’t imagine having to use the Railway’s default UI to manage all running services.
Or should I build it myself since it doesn’t exist?
——
Unfortunately, in my use case, the user will use the service 24/7, thus the reason why a dedicated service has to be spawned for each of the subscribed users.
Thanks, I will try it. Though I think at the end I'd have to build a simple dashboard that connects to Railway's GraphQL API to manage all those services in case I need to manually override their lifecycles.
I am building a cloud-based trade copier SaaS.
Each subscribers can add/delete their trading accounts in their dashboard based on their plan.
For every connected trading accounts created by the users, a headless instance of the platform (cTrader/MT4/MT5/TradeLocker) will have to be spawned as a standalone service on Railway.
That’s the alternative, but based on our initial tests, running multiple instances of the platforms in the docker image via wine (using Ubuntu as base OS) seems to degrade the performance. So that’s why we opted to spawn dedicated services for each users instead.
exactly, that's why I wanted to know about this scalability issue. I should mail them just to be sure.
on paper, it seems ok.
and Railway is perfect for this, because it only calculates based on the usage (unlike other PaaS like Northflank for example which would charge you the minimum amount for every service spawned)
oh I didn't know that this Discord thread is relayed to the official help page. I will mention the support team there.
https://help.railway.app/questions/questions-about-scalability-7fc87530
2 years ago
Hi support team,
Can anyone from the official support team confirm if my use case described in this thread is something that Railway would be okay with?
Best,
Agast
2 years ago
I'll throw my 2 cents in, Railway aside, a service for every user is absolutely not scalable or even maintainable, regardless of doing them as separate deployments or docker-in-docker, I would advise you to heavily re-think your projects architecture
Hi @Brody, thank you for the insights. To be honest, I am not sure if I'd go on with that approach.
The thing is that the app that I have to run can only run under wine on Linux. And based on my initial testing, having multiple of this app running under Wine would degrade the performance a lot.
So instead of using 1 Linux host with multiple apps running under wine, I was thinking about running multiple hosts instead.
2 years ago
I just don't think you should be running multiple of anything for each user, that honestly sounds like a horrible architectural design
After running some more tests… I think you’re right. Most of the resources are spent in RAM used by the base OS.
The app itself that needs to be run under Wine is actually lightweight. But the overhead cost to run the OS is too much.
hi, sure, my alternatives would be to use K8S instead for easier maintenance and configurations.
it's still working time in my timezone but I will message you when I am free 😄
would love to discuss this with people that have more experience on this matter