Web Dev T
Web Dev T

Reputation: 193

Multiple-language microservice approach

this is rather a straightforward question, i've tried to find something about it but either im totally out of my mind or it is not so easy to find out, Is there a way to have say: Microservice 1 (in Nodejs) and Microservice 2 (in Python) under the same ApiGateWay (Nodejs Express) ... i made it work using Nodejs (express) as gateWay and 2 Microservices in Nodejs (Cote.js) with no problem at all, but now i need part of the logic in python (Flask) .. what is the best approach to use a second language? i read something about an internal restApi but i could not find any clear example.

by the way: If Docker helps i can totally use it, don't hesitate about it.

Upvotes: 1

Views: 1838

Answers (3)

Kesha Saparow
Kesha Saparow

Reputation: 1

yes it's good idea.Facebook You tube and other companies uses this architecture in their projects.You must run microservices different ports

Upvotes: 0

Mohamed Belkamel
Mohamed Belkamel

Reputation: 429

A good approach to your problem would bes using nginx routing, let's say in the configuration file of nginx, you could do

location /api/v1 {
proxy_pass http://localhost:4000;
}

and you would have your node js api running there, and a different routing pointing to your python api on:

location /api/v1/ms2 {
proxy_pass http://localhost:4001;
}

and then have your front end point to which ever is needed at that time, and boom you have two different languages running on the same server serving the same front-end

Upvotes: 1

herm
herm

Reputation: 16315

Its a rather usual case to have different microservices use different technologies. However they need an api to communicate with each other. Often that is a rest api. For example Microservice 1 listens on port x to requests. Depending on the requested url path (e.g /hello-world) it will return a string representation (e.g json) of the requested data.

Docker can help you with setting the ports of the services and glueing everything together.

Upvotes: 3

Related Questions