100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
Web

Moleculer

A fast, fault-tolerant microservices framework for Node.js

AdvancedFramework10.4K learners

js microservices framework providing built-in service discovery, load balancing, request/event-based inter-service communication, and resilience patterns like circuit breaking, without requiring an external orchestration layer.

Definition

Moleculer is a fast, fault-tolerant Node.js microservices framework providing built-in service discovery, load balancing, request/event-based inter-service communication, and resilience patterns like circuit breaking, without requiring an external orchestration layer.

Overview

Moleculer targets a different problem than typical HTTP frameworks: rather than serving individual API requests, it manages communication and coordination between many independent microservices running as separate Node.js processes. Each Moleculer 'service' defines a set of actions (RPC-style callable methods) and can emit or listen to events; the framework handles discovering other running service nodes, routing calls to them, and balancing load across multiple instances of the same service — all without requiring a separate service mesh or orchestrator to be deployed. Communication between services is transport-agnostic: Moleculer can run entirely in-process for local development (with zero network overhead), or use a real message transporter — NATS, Redis, MQTT, Kafka, or TCP gossip-based discovery — in production, letting the same service code scale from a single process to a distributed cluster without code changes. Built-in load-balancing strategies (round-robin, random, CPU-usage-based) distribute action calls across available service instances automatically. Moleculer includes resilience patterns out of the box: circuit breakers that stop calling a failing service after repeated errors, retry policies, request timeouts, and bulkhead-style concurrency limiting, all configurable per action. It also ships a built-in API gateway module (moleculer-web) that exposes internal services as a REST API, letting a Moleculer-based system present a conventional HTTP interface to external clients while communicating internally via its own RPC protocol. Moleculer is chosen by teams building Node.js microservice architectures who want these distributed-systems concerns (discovery, load balancing, fault tolerance) handled by the application framework itself rather than by external infrastructure like Kubernetes service meshes or dedicated message brokers configured by hand.

Key Features

  • Built-in service discovery and dynamic load balancing across service instances
  • Transport-agnostic communication: in-process for dev, NATS/Redis/MQTT/Kafka/TCP for production
  • Circuit breaker, retry, timeout, and bulkhead resilience patterns per action
  • Request/response (action) and publish/subscribe (event) communication models
  • Built-in API gateway module (moleculer-web) exposing services as REST endpoints
  • Versioned services and mixins for shared cross-service behavior
  • Built-in metrics, tracing, and structured logging integrations

Use Cases

Node.js microservices architectures needing built-in service discovery and load balancing
Systems requiring resilience patterns like circuit breaking without a separate service mesh
Event-driven backends coordinating many small, independently deployable services
IoT and real-time systems distributing work across multiple worker processes
Gradual migration of a monolith into microservices while sharing in-process transport during development

Alternatives

Feathers.js · Feathers contributorsNestJS microservices · Kamil MyśliwiecgRPC · Google

Frequently Asked Questions