containerization
Im thinking about implementing multiple techs/languages in a monolith. Does the containerization makes it possible
39 Replies
@cfkeef
So as i was saying. Containerization is really just being able to have a process to create a binary thats explicit. A monolith will take advantage of this when you move to deploying it into the world and setting up ci&cd
But if you want to have a Rust codebase that also does some python work you need to be looking at foreign function interface more then style of system (monolith,micro)
I skimmed the chat earlier and you said you were doing a web api and a ml processor yeah?
why not just set them up as two seperate services?
That is, assuming you want it to be one service.
by monolith he does is my assumption
Monolith can be many apps.
could be but then they would say distributed monolith
hence monorepos
WOULDNT THEY
I mean i asked about microservices yesterday and they told me use monolith instead 🤷🏻♂️
Afaik monolith is one service
i don't even know if i'm properly defining things since the definitions can be very wide. A microservice technically should be owning its own data (has its own database, seperately deployed etc)
So how can i make my ML in a separate service
Oh i see now
but doing cross language stuff is more baggage then just having a service that service what the ml service is cooking just seems easier and the seperation is pretty clear
If thats what you are doing then its fine but I was under the assumption you are just trying to deploy 1 thing that'll make use of ffi
So basically put the ml model in a separate docker container in a separate server
it can be pretty loose. you can just have a server that runs docker compose for both of your apps and be fine
you can seperate their compute (one server for each yadda yadda)
Nd how those dockers communicate?
welcome to a whole ass world
what flavor do you want
async or synch
async you can look at message queues, sync http
grpc is another flavor of sync i think
So basically internal server communication 😕
server 2 server usually in a private network
Nd how can i make it?
Through api?
And that still a monolith?
i think the apt term is distributed monolith since we are probably using the same database for all of them and communicating through network means. like i said the definitions between monolith and microservice have several connotations that aren't just how many things you are deploying at the end of the day
Hmmm so technically using multiple techs/languages in a monolith is possible by using dockers nd make some communications between them
What if i put the two dockers in one server
its still gonna be the same thing
its jsut on one system
Nd for caching i have to use kubernetes
To manage the dockers
no
Caching what?
Docker by itself will cache your layers if they don't change between builds
Kubenetes is just a means to an end for orchestrating containers
its docker compose + alot of extras
Aah i see, is that the only possible way to use multiple languages in a monolith?
So
When you say that what do you mean? Do you want multiple services so that language doesn't matter or do you want one single deployment that will call multiple languages
if its the latter containerization isn't relevant thats just ffi (foreign function interface)
if itsthe former containerization is the start to getting to where you'd want to be
I have my backend with node js but im using some ml models in python to parse some data nd send it to the node backend to store it in the db
send it back
so you are doing something with network communications?Well its like the user upload a pic to the app. The backend have to parse that picture with an ml model croping it to make it look consistent then store it in the db or the s3 bucket
Ofc i'll use other ml model to match that pic with another pictures
So is that possible in a monolith
So I"ll ask you
What do you mean by monolith?
Its clear to me what you can do here and I've answered it but I'm not sure how to further explain it without repeating what i said before
Take that nicely I really don't mean it in a bad way
Afaik putting all ur backend logic in single codebase with a single database.
Nothing personal dw
So now I ask how do you plan to execute this python code from your nodejs?
I mentioned languages can interface with other languages using ffi. Is that something you want to persue?
In rust u can do that by using other scripts idk if its possible in node js
That's interesting
it probably can but if you are already using a monorepo (turbo repo with two apps: nodejs api and the python worker) the easier path in my opinion is to just deploy them seperate and using http for communication or a message queue
they can share the same codebase, same database but the deployment strategy is separated which makes it a distributed monolith
nodejs can prob do ffi i imagine
I got it now so either the first option which is deploying them separately or going for ffi
Cool
Everything may work fine now
But eventually, you may shoot yourself in the foot
How
I can't categorically tell you how
But only use this when it's actually needed and very important
Because I know from here you will enter Kubernetes etc😀
Yeeh