Questions about scalability
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
Project ID:
N/A
N/A
No response so far. Maybe I should contact the support instead 😅
i will try to respond.
you can use the Railway api to create services on the fly, you can also shut it down trough the API.
Im not sure about the build command being changed, however you should be able to modify the start command.
the amount of 300 upto 500 services seems like alot to me, maybe its an idea to reconsider your setup?
in 99% of the cases, users are not using a service 24/7
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 service
- upon 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.
the answer on your UI question:
you could do multiple things:
1. create a project for each
2. try to find a way to create them in a service group (https://help.railway.app/feedback/service-groups-c1faed81)
3. create a project for all customer services, to keep the system/customer services seperate
(keep in mind that seperate projects would result in more egress costs)
Railway Help Station
Service Groups
The ability to drag and drop services on the canvas and group them visually
might i ask what kind of service you provide?
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.
and there is no way to combine that into a single service (scaled horizontally)?
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.
i see, not sure if there is a max amount of services
for that you can probs mail railway
i could understand if they dont like it, if you have 300 services and your gonna rollout an update, it will build 300 times 😅
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)
but I will ask the official support just to be sure.
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
Railway Help Station
Questions about scalability
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...
New reply sent from Help Station thread:
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, AgastYou're seeing this because this thread has been automatically linked to the Help Station thread.
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.
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.
I’ll need to consider other approach. Thank you @Attacler/Bart & @Brody
No problem!
Just to double check, there is no api or anything for those programs?
No API at all. That’s why I have to go a long way 😅
good luck...
you might have to consider to just get a dedicated server (or VPS) to run this
its not billed by the hour but more flexible.
or connect K8S and some VPS`s together (that way maintance can be way better)
and to reduce the amount of instances/services, you might be able to bundle calls (for example keep 1 instance alive for fetching pricing data, while the others are there to execute orders for the customer)
altho im not 100% sure how your platform/idea would run
if you want, you can add me and discuss a bit
hi, sure, my alternatives would be to use K8S instead for easier maintenance and configurations.
I just added you
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
thank you so much!
no problem at all 🙂