Giter Club home page Giter Club logo

Comments (10)

vahidvdn avatar vahidvdn commented on August 13, 2024 2

@YisusYaro Thanks for your explanations. They make sense to me.
But, here is my concern. One of the reasons that we use microservices is that if one part of the project is down, the user is not going to be blocked, so whenever that part is up again, the message broker can give the message to that part.
But in this case, if the gateway itself is going to be down, what will happen?

from nestjs-microservices-example.

YisusYaro avatar YisusYaro commented on August 13, 2024 1

@YisusYaro How about having a gateway for each microservice?

Talking about nestjs, having a gateway for each microservice for me it's definitely not good idea, you will to create two events loops, using more ram needlessly, you can directly create an hybrid aplication (http and other transport).

Assuming that you create an hybrid aplication, this option is the best for scalability if you have the hardware necesary for run pararely, but if you don't have the suficents cores, you will to use more ram needlessly and finally cpu time will be shared.

Even if you have the hardware, direct client-to-microservice communication have other disventages, for me an microservice should not have the responsability of secure it's comunication, or validate jwt for example.

I always try to create MICROservices focuseds in their utility, yes MICRO in caps.

But, how to resolve this?, You need to secure thar do not block the event loop in your gateway, this maitain a fast entry for client petitions, taking advantage of the asynchronism of nodejs, and finally you can create reals microservices.

If you do not block the gateway, and anyway you have so much latency, you can scale your gateway horizontally, but maintaing the advantages of having only an entry for you app.

from nestjs-microservices-example.

mxkh avatar mxkh commented on August 13, 2024 1

@vahidvdn API gateway scaling horizontally very well. You could do that with K8S HPA and CA. The benefit of having one API gateway is that you have a single entry point to your microservices that will

  • Rate limit
  • Auth
  • Communication through different protocols with your microservices

and many other valuable things. Otherwise, you will repeat all these tasks for each microservice in your cluster.

from nestjs-microservices-example.

YisusYaro avatar YisusYaro commented on August 13, 2024

The api gateway scales well both horizontally and vertically.

from nestjs-microservices-example.

vahidvdn avatar vahidvdn commented on August 13, 2024

@YisusYaro How about having a gateway for each microservice?

from nestjs-microservices-example.

avifatal avatar avifatal commented on August 13, 2024

@vahidvdn I think you got a big point here, if you want parts of your app to be alive while other parts are down, youll need slim controllers for each microservice and you should reuse the authentication on these controllers/gateways.

The internal communication (microservice to microservice) should be unsecured (maybe pass the user info inside the context for the benefit of createdBy and updatedBy) .

this way if one MS is down, the others are still functioning and secured (as long as they are not totally depending on each other, because in this case, one microservice is down the entire stack will be down...)

from nestjs-microservices-example.

vahidvdn avatar vahidvdn commented on August 13, 2024

@avifatal So you mean we should have a gateway for each microservice separately?

from nestjs-microservices-example.

avifatal avatar avifatal commented on August 13, 2024

@vahidvdn in my opinion yes. if you want each MS to be independent, you don't want to create single point of failure - AKA one gateway for all. (it makes security a little bit more complex).
On the other hand, if all MSs are relaying on each other and they speak frequently, I would go with the current architecture presented in this wonderful repo.
I think the biggest drawback of nest is that its micriservices mechanism is not a real framework its just an abstraction of communication layer. once things like security will be solved there, it would make it really convenient to use.
@YisusYaro Ill be happy to know your thoughts about this issue (security and single point of failure wise)

from nestjs-microservices-example.

sinhpn92 avatar sinhpn92 commented on August 13, 2024

Each gateway for each service doesn't solve your issue @vahidvdn. It won't solve your problem. The way you give is just a situational solution and it is not a good way. You can research about NodeJS Microservices Zero Downtime.

from nestjs-microservices-example.

vahidvdn avatar vahidvdn commented on August 13, 2024

Thank you guys, this is already fixed for me. Thanks for the collaboration

from nestjs-microservices-example.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.