npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

redux-cluster

v2.0.63

Published

TypeScript cluster module for Redux that synchronizes Redux stores across cluster processes via IPC and TCP sockets

Downloads

1,259

Readme

Redux Cluster 2.0

npm npm NpmLicense GitHub last commit GitHub release

A modern TypeScript library for synchronizing Redux stores across multiple processes and machines using TCP, Unix Domain Sockets, and IPC.

🌐 Need WebSocket support for browsers? Check out redux-cluster-ws - our companion package that extends Redux Cluster with WebSocket transport for browser clients.

🌟 Key Features

  • 🔄 Real-time State Synchronization across multiple processes/machines
  • 🌐 Multiple Transport Options: TCP, Unix Domain Sockets, IPC
  • 🌍 WebSocket Support: Available via redux-cluster-ws
  • 📡 Bidirectional Communication - any node can dispatch actions
  • 🔒 Built-in Security with authentication and IP banning
  • High Performance with optimized networking and compression
  • 🏗️ Master-Slave Architecture with automatic leader election
  • 🔧 TypeScript First with comprehensive type definitions
  • 🎯 Redux Compatible - works with existing Redux ecosystem

🏛️ Architecture Overview

Redux Cluster implements a master-slave architecture where one server manages the authoritative state and distributes updates to all connected clients:

┌─────────────────────────────────────────────────────────────────┐
│                        Redux Cluster Network                    │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  ┌─────────────┐         TCP/Socket          ┌─────────────┐    │
│  │   Client A  │◄───────────────────────────►│   Server    │    │
│  │  (Worker)   │                             │  (Master)   │    │
│  └─────────────┘                             │             │    │
│                                              │             │    │
│  ┌─────────────┐         TCP/Socket          │             │    │
│  │   Client B  │◄───────────────────────────►│             │    │
│  │  (Worker)   │                             │             │    │
│  └─────────────┘                             └─────────────┘    │
│                                                       │         │
│  ┌─────────────┐         TCP/Socket                   │         │
│  │   Client C  │◄─────────────────────────────────────┘         │
│  │  (Worker)   │                                                │
│  └─────────────┘                                                │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Data Flow

┌─────────────┐    1. Action     ┌─────────────┐    2. Process   ┌─────────────┐
│   Client    │─────────────────►│   Server    │────────────────►│    Redux    │
│             │                  │  (Master)   │                 │   Store     │
└─────────────┘                  └─────────────┘                 └─────────────┘
       ▲                                │                               │
       │                                ▼                               │
       │         4. State Update  ┌─────────────┐    3. State Changed   │
       └──────────────────────────│  Broadcast  │◄──────────────────────┘
                                  │   Engine    │
                                  └─────────────┘
                                         │
                                         ▼
                              ┌─────────────────────┐
                              │    All Clients      │
                              │   (Auto-sync)       │
                              └─────────────────────┘

🚀 Quick Start

1. Installation

npm install redux-cluster redux

2. Basic TCP Example

Server (Master):

const { createStore } = require('redux-cluster');

// Simple counter reducer
const counterReducer = (state = { counter: 0 }, action) => {
  switch (action.type) {
    case 'INCREMENT': return { counter: state.counter + 1 };
    case 'DECREMENT': return { counter: state.counter - 1 };
    default: return state;
  }
};

// Create store and server
const store = createStore(counterReducer);
const server = store.createServer({ port: 8080 });

console.log('Server started on port 8080');

// Server can dispatch actions
store.dispatch({ type: 'INCREMENT' });

Client (Worker):

const { createStore } = require('redux-cluster');

const store = createStore(counterReducer);
const client = store.createClient({ 
  host: 'localhost', 
  port: 8080 
});

// Client receives all state updates automatically
store.subscribe(() => {
  console.log('New state:', store.getState());
});

// Client can also dispatch actions
store.dispatch({ type: 'INCREMENT' });

🌐 Transport Options

Redux Cluster supports multiple transport mechanisms:

TCP (Network)

// Server
const server = store.createServer({ 
  host: 'localhost',
  port: 8080 
});

// Client  
const client = store.createClient({ 
  host: 'localhost',
  port: 8080 
});

Unix Domain Sockets (Local)

// Server
const server = store.createServer({ 
  path: '/tmp/redux-cluster.sock' 
});

// Client
const client = store.createClient({ 
  path: '/tmp/redux-cluster.sock' 
});

IPC (Node.js Cluster)

import cluster from 'cluster';

if (cluster.isMaster) {
  const store = createStore(reducer);
  cluster.fork(); // Start worker
} else {
  const store = createStore(reducer);
  // IPC automatically enabled in cluster workers
}

🔧 Configuration Options

Server Configuration

const server = store.createServer({
  host: 'localhost',     // TCP host
  port: 8080,           // TCP port  
  path: '/tmp/app.sock', // Unix socket path
  logins: {             // Authentication
    'user1': 'password1',
    'user2': 'password2'
  }
});

Client Configuration

const client = store.createClient({
  host: 'localhost',     // TCP host
  port: 8080,           // TCP port
  path: '/tmp/app.sock', // Unix socket path
  login: 'user1',       // Authentication
  password: 'password1'
});

Store Configuration

const store = createStore(reducer, {
  mode: 'action',           // 'action' | 'snapshot'
  serializationMode: 'json', // 'json' | 'protoobject'
  debug: false,             // Enable debug logging
  resync: 30000            // Resync interval (ms)
});

📊 Synchronization Modes

Action Mode (Default)

Actions are distributed and replayed on all nodes:

Client A: dispatch(ACTION) ──► Server ──► broadcast(ACTION) ──► All Clients
                                  │
                                  ▼
                              Apply ACTION to master state

Snapshot Mode

Complete state snapshots are distributed:

Client A: dispatch(ACTION) ──► Server ──► calculate new state ──► broadcast(STATE) ──► All Clients

🔒 Security Features

Authentication

const server = store.createServer({
  logins: {
    'api-service': 'secret-key-123',
    'worker-pool': 'another-secret'
  }
});

const client = store.createClient({
  login: 'api-service',
  password: 'secret-key-123'
});

IP Banning

Automatic IP banning after failed authentication attempts:

  • 5+ failed attempts = 3 hour ban
  • Automatic cleanup of expired bans
  • Configurable ban policies

🎮 Examples

See the examples/ directory for complete working examples:

🌐 WebSocket Examples: For browser integration examples with WebSocket transport, visit the redux-cluster-ws examples.

Each example includes a README with step-by-step instructions.

📦 Related Packages

redux-cluster-ws

WebSocket transport layer for Redux Cluster, enabling browser client support:

npm install redux-cluster-ws

Features:

  • 🌐 WebSocket server and client
  • 🔗 Seamless integration with Redux Cluster
  • 🖥️ Browser support for web applications
  • 📱 Real-time state synchronization to browsers
  • 🔒 Same security features as core package

Links:

🧪 Testing

# Run all tests
npm test

# Run specific test suites
npm run test:unit       # Unit tests
npm run test:transport  # Transport integration tests

# Build and test
npm run build
npm run lint

# Run full integration tests (includes Docker)
npm run test:integration-full

📈 Performance

Redux Cluster is optimized for high-throughput scenarios:

  • Compression: gzip compression for all network traffic
  • Binary Protocol: Efficient binary serialization options
  • Connection Pooling: Reuse connections where possible
  • Minimal Overhead: < 1ms latency for local sockets

Benchmark results:

  • TCP: ~10,000 actions/sec
  • Unix Sockets: ~50,000 actions/sec
  • IPC: ~100,000 actions/sec

🗺️ Roadmap

  • [ ] Redis Transport - Redis pub/sub for clustering
  • [x] WebSocket Transport - Available in redux-cluster-ws
  • [ ] Conflict Resolution - CRDT-based conflict resolution
  • [ ] Persistence Layer - Automatic state persistence
  • [ ] Monitoring Dashboard - Real-time cluster monitoring
  • [ ] Load Balancing - Multiple master support

🤝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Setup

git clone https://github.com/siarheidudko/redux-cluster.git
cd redux-cluster
npm install
npm run build
npm test

📄 License

MIT License - see LICENSE file for details.

🆘 Support

💝 Support This Project

If Redux Cluster helps you build amazing applications, consider supporting its development:

Your support helps maintain and improve Redux Cluster for the entire community!


Made with ❤️ by Siarhei Dudko