top of page

What is the Difference Between NestJS and Moleculer Js


NestJS



Nest.js is an open source MIT-licensed progressive Node framework, written in TypeScript and sharing many concepts with Angular. It’s for the server side and can be used to build efficient, reliable and scalable web applications for the enterprise. It’s built by Kamil Mysliwiec.


Nest.js has features such as:

  • Extensibility: Thanks to its modular architecture, Nest allows you to use the other existing libraries in your project.

  • Architecture: Nest has a project’s architecture that provides effortless testability, scalability, and maintainability.

  • Versatility: Nest provides an ecosystem for building all kinds of server-side applications.

  • Progressiveness: Nest makes use of the latest JavaScript features and implements mature solutions and design patterns in software development.


Moleculer JS


Moleculer is a fast, modern and powerful microservices framework for Node.js. It helps you to build efficient, reliable & scalable services. Moleculer provides many features for building and managing your microservices.


Moleculer JS has features such as:

  • Blazing fast: High performance microservices framework.

  • Extensible: All built in modules (caching, serializer, transporter) are pluggable.

  • Open Source: Moleculer is 100% open source and free of charge project. All source code is available under MIT license on GitHub.

  • Fault Tolerance: Moleculer is fault tolerant framework. It has built-in load balancer, circuit breaker, retries timeout and bulkhead features.



Difference Between Nest JS and Moleculer JS


Nest JS Moleculer JS

General

Advantages: Writing code is easy and well structured. Framework is similar to Angular, Vue and React. Uses Dependency injection for calling any micro service or internal service files. Disadvantages: Need to create Config files for each microservice for connection.

Advantages: All the features around the services are config based, its easy to standardise all the microservices. Performance is really fast than any other competitors. Disadvantages: Need to create service Broker for each service (not sure how much maintainable it will be)

Highly Availability and Fault Tolerant

Advantages: Give us more flexibility to own the functionality of all the fault tolerant mechanism. which mean we have to re-invent the wheel or use the tools available in market. Disadvantages: Need to create the functionality from the scratch which is an overhead on the team who is creating boiler plate packages and since the functionality is on service side they can mishandle the same

Advantages: Has Inbuilt functionality of circuit breakers, timeouts, retry, fallbacks, which can reuse or bundle them in boiler plate package. No need to ask for any other tools available in market. Easy to introduce fail fast mechanisms via configs. Disadvantages: N/A

Scalability

Since node is single threaded event loop process, the only way to scale system is via load balancers

same as Nest.JS

Ease of Introducing New MicroService

Advantages: All the logic of connecting to service or calling internal service is filled in based on Factory Pattern so it will be easy to replace the Provider classes and doing API call instead or internal method call. Disadvantages: All the functionalities to support the MicroService has to be written again like circuit breakers, timeout etc.

Advantages: Since doing a call to new Microservice is done at service broker level it will be easy to point the new service. For this we shall follow certain design decorum in code which will allow us to follow configs well. Once we create a fresh new Microservice via molecular we will get the supported tools in package itself like circuit breakers, timeouts etc. Disadvantages: Need to think of service Bus and message brokers.

Performance

Similar to Express

As their document says Blazing Fast.

Inter Service Communication

Abstraction: If we design Nest.JS well by using proper Dependency Injection we can abstract the inter service communication. Support: all gRPC, TCP etc.

Abstraction: Abstracted vis Service Broker. Support: all gRPC, TCP etc.

Latency

Considering Network Latency as constant, internal process time for Nest.JS is similar to express

Considering network latency as constant. Internal process time for molecular is faster. Which eventually reduces the latency of inter communication between services.

Consistency

Can be achieved via Load Balancers, need to create logic.

Can be achieved via Inbuild Service Broker or Load Balancers or Both. Supports versioning out of the box via inbuild functionalities.

Durability

Both are same

Both are same

DB, Caching, Support

Pros: Supports almost all types of DB and Catching. Cons: Need to write code for connections.

Pros: Supports all types of DB and Catching, Provides internal supports for Redis, No need to write extra connectors. Hence boiler plate code will be easy to create.

Additional Point of Failure

N/A

We have to use service broker and message broker, this message broker can lead to additional point of failure in our system

Security

Need to Implement

Has Inbuild JOI and other features to handle security and sanity of incoming request



Resource: Medium - Anshul Basandani


The Tech Platform

0 comments

Recent Posts

See All
bottom of page