Answer the question
In order to leave comments, you need to log in
Node js rest api one or many?
I have a server for Rest Api ( https://vk.com/api4e1)
Api manages data in mongodb. Messages, Users, authorization and other modules, each is written in a separate js file and is standalone.
Question: is it better for everyone to be launched by a separate process and listen to their own port? Or is it better to make one process that will simply manage all the data?
PS nginx is responsible for redirection
Option 1:
A separate process for messages.js that listens on port #1000
A separate process for users.js that listens on port #1001
, etc.
nginx already redirects the request to different ports depending on the url
Option 2:
The only process for server.js that is listening on port #1000
nginx sends all api requests to this port
Answer the question
In order to leave comments, you need to log in
According to the process for the js file, this is something like microservices. If they are so self-contained that they can be cut into processes without any extra effort, I would do so.
The advantage is that in the future they can be taken apart by different machines. M - Scaling.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question