Railway deploy for microservice architecture
Hey guys, how are you? I'd be happy if you could help me.
I am entering the world of microservice archtecture and would like to know how to properly handle it in railway or even if it is suitable for it.
The two main topics i can think about are:
- Deploying: Since railway does not seem to support docker-compose, does deploy needs to be manual? It does not seem to have private templates too
- Scaling: How could if i need to expand my app/system for another company or similar case? Is there something that could handle services groups like kubernetes' namespaces?
How would I setup the deploy? Thank u!
28 Replies
Project ID:
N/A
N/A
railway does have private templates in some sense, it was just recently added! haven't tried it myself but sources of services can deploy from private repos now.
there is no docker-compose support in the sense you are likely thinking, they can only be used to scaffold a template, and I don't think a template is what you want, so I personally wouldn't go that route.
so yes, "deploying a docker-compose" file is a manual process, you basically need to manually translate it into a railway project, does your docker compose file have a postgres database? then you add a postgres database to your project, does it have redis, then you add redis, do you have a queue app, then you add a service and set it up the same way it's defined in your compose file, and so on until you have your docker compose file decomposed into a railway project.
I have no experience with k8s, so please help me to understand what namespaces helps with so I can try to relate that to railway for you.
Thank you for your answer Brody.
That's great news we have private templates now! It will surely solve most of my problems.
About namespaces it is basically a way of horizontal scalling apps.
Let's say i have a Support Manager app with a db service, a support ticket service and a chat service. Also, i have a platform that enterprises can apply for utilyzing my app. After the request is completed my platform automatically creates a namespace for the new enterprise and replicates my Support Manager infra into it with the enterprise configuration(like business name, admin password, etc)
ah so it basically spins up a whole new app (and needed infra) upon request?
yep
does that mean your app is single tenant only? and you are just spawning multiple apps for each user?
Yes, i'd be creating a tenant for each new enterprise that would like to use the app
do you currently hook into the k8s api or something to achieve that now?
actually no, i am yet deciding about the infra and railway have always been my favorite hosting service
i assume a multitenant application is off the table?
Well, mostly yes. My main goal is scalability and customization
i would not regard single tenant applications as scalable, sure they can be scaled, but not efficiently, you would need to use railway's api to put together something that will deploy a new app every time someone is granted access to it
for example, having a database for every user is not cost effective for most cases
Oh i see what you thinking about, let me clarify the situation
ProductApp: The app to be sold, microservice structure, multitenant, scalable por large user quantity.
ManagerApp: The app that handles new companies interested in the ProductApp, what services will or will not be included in the app etc. Scalable in the sense of attending different ProductApps for multiple companies, each with full resource isolation and offers different features depending on company requirements
Does that make sense to you? I am not a experienced infra designer myself, so i am very open to suggestions
Also, let me point out that it can be kinda of achieved with the private templates you mentioned with a lot more manual work, so its not a big deal right now, i am just thinking ahead
do you need to deploy a productapp for every client it's sold to?
yep
I'm struggling on seeing how that is multi-tenant
can you explain me why? maybe i am just struggling with concepts
you said you need to deploy productapp for every client, that is what the left of this image depicts
okay i see
The productapp if for an enterprise right? the enterprise would be the owner of the app and have it configured for its needs, so its costumers can use it, you see?
the costumers would all share the same database, as in multitenant archtecture
but there are various productapps that have been sold to companies, each with its own db and resources, as in singletenant architecture
so...
ManagerApp: a few dozen users, each user with its own isolated productapp, isolated db, etc
Each ProductApp: MultiUsers, couple hundred per app maybe? Every user share the same db
why not sell access to a single multi-tenant application? the way you are currently doing it doesn't seem super scalable
nor resource efficient
For a single multi-tenant app, i d have to handle 3 types of user: Company, CompanyEmployee, CompanyUser
I see your concerns about it.
For each service in this single multi-tenant app, i'd have to handle wich user type i am dealing with and where it belongs. After defining this, i would have to handle if the permission, this would involve:
- is the route for employees?
- is the route for comapny costumers?
- does the company have access to this feature?
This not only makes the data models more complex but also the distribution of responsabilities between the services kinda odd i think.
Think about an app that offers companies a way for its costumers to create appointments with its employees
Models for a single multi-tenant:
Company: #id, name, ...other company info...
User: #id, name, password, company, user_type
Appointment: #id, datatime, employee, costumer
Services:
AdminPanel: see, edit or delete apointments from costumers
AppointmentManager: allow costumers to create or cancel appointments
So far so simple, but what if a company actually wants appointments to be notified via email everytime they are made?
Then i would need to handle which companies have access to this feature, then i would need to check what is the company configuration, adding more complexity for its model and the necessity of a new email_notifier service.
Do you think i am neglecting the costs a single-tenant architecture?
I see what you mean, and yes it would be more involved initially than a single tenant application, but I think it would be time well spent to do that, Vs spending your time trying to get railway to deploy your app for every user you get.
if you wanna go the single app per single user thing, you better have one hell of a price markup.
if you did a single multi-tenant app with railway you could scale vertically as high as you want.
i see, thank Brody, i think i am more inclined to your approach now
one more question tho. You think that one DB per company would still be efficient?
considering a freshly deployed postgres database uses 90 or so MB at idle, plus you'd end up having the same tables so that's another base amount of disk usage, scale that up to how ever many users you get, that's not ideal in my opinion
I see, thank u
I think that finishes this topic
happy to help!