K
K
komarevtsev2016-06-21 16:56:31
JavaScript
komarevtsev, 2016-06-21 16:56:31

How to properly split a node js application into microservices?

How to properly split a node js application into microservices?
I use express 4.
Does it make sense to take out, for example, a chat or any other part, the logic of which differs from the main application, into a separate node application?
How, in this case, to communicate between applications (http requests are now implemented for me)

Answer the question

In order to leave comments, you need to log in

4 answer(s)
V
Vladimir Grabko, 2016-06-21
@VGrabko

Well, in general, there is usually an "entry point" that has a public Api and is busy proxying requests to microservices.
About the protocol.
I use Go and I think that it will also work with any PL.
I have done something like json RPC over TCP and UNIX SOCKET between microservices. The second is done in cases where microservices are on the same server and each microservice listens to both tcp and unix socket.
Usually, each module is taken out to a microservice (a la Authorization, Chat, Sending EMAIL, etc.)

D
Dmitry, 2016-06-30
@saDam

Try reading here:
A very good guide to microservices: https://www.nginx.com/blog/introduction-to-microse...
node.js: codewinds.com/blog/2015-11-14-microservices-nodeve. .. ( https://github.com/jeffbski/microservices)

A
Antoxa Zimm, 2016-06-24
@AntoXa_ZiMM

I think that node.js may well use the general principles of microservice architecture, the implementation depends on imagination and experience.
According to the experience of a social network project on microservices and a message bus:
A small piece of logic is taken out into several microservices, for this piece of logic it is usually easy to create a schema in the database (usually 1-4 tables) and prohibit other services from accessing this schema. If the service (or several) is written correctly, then it can easily be transferred from one site to another without unnecessary problems with integration.
Services can be divided into different types:
For communication, microservices can use RabbitMQ with some kind of wrapper on top of it.

I
Ivan Zmerzlyi, 2016-06-30
@DangelZM

At one time, I also thought about the issue of organizing projects. For a few personal and a couple of bespoke projects, I started to organize the structure based on high-level modules.
According to the requirements that stood before me, I needed to create projects in which there is an admin panel SPA (Single page application), there is an API, and there is a public part (front, muzzle) which for one project can be SPA, for another it’s purely a monolith with rendering views.
As a result, it turned out such a basis - https://github.com/DangelZM/simplicitjs Now there is no time to refine it somehow. But it came in handy for me to start small projects with admin panels.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question