All Projects → fent → Clusterhub

fent / Clusterhub

Licence: mit
Sync data in your cluster applications.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Clusterhub

Jupiter
Jupiter是一款性能非常不错的, 轻量级的分布式服务框架
Stars: ✭ 1,372 (+939.39%)
Mutual labels:  cluster
Clusterws Client Js
🔥 JavaScript Client for ClusterWS - lightweight, fast and powerful framework for building scalable WebSocket applications in Node.js.
Stars: ✭ 120 (-9.09%)
Mutual labels:  cluster
Ecs Exporter
Export AWS ECS cluster metrics to Prometheus
Stars: ✭ 127 (-3.79%)
Mutual labels:  cluster
Redis Tools
my tools working with redis
Stars: ✭ 104 (-21.21%)
Mutual labels:  cluster
Php K8s
PHP K8s is a PHP handler for the Kubernetes Cluster API, helping you handling the individual Kubernetes resources directly from PHP, like viewing, creating, updating or deleting resources.
Stars: ✭ 111 (-15.91%)
Mutual labels:  cluster
Cv4pve Autosnap
Automatic snapshot tool for Proxmox VE
Stars: ✭ 123 (-6.82%)
Mutual labels:  cluster
Kurasuta
A Custom discord.js Sharding Library inspired by eris-sharder.
Stars: ✭ 101 (-23.48%)
Mutual labels:  cluster
Ansible Rpi K8s Cluster
Deploy Raspberry Pi Kubernetes cluster using Ansible
Stars: ✭ 131 (-0.76%)
Mutual labels:  cluster
Textcluster
短文本聚类预处理模块 Short text cluster
Stars: ✭ 115 (-12.88%)
Mutual labels:  cluster
Our Postgresql Setup
PostgreSQL clustering with corosync/pacemaker test environment
Stars: ✭ 126 (-4.55%)
Mutual labels:  cluster
Awx Ha Instancegroup
Build AWX clustering on Docker Standalone Installation
Stars: ✭ 106 (-19.7%)
Mutual labels:  cluster
Clustermq
R package to send function calls as jobs on LSF, SGE, Slurm, PBS/Torque, or each via SSH
Stars: ✭ 106 (-19.7%)
Mutual labels:  cluster
Black Widow
GUI based offensive penetration testing tool (Open Source)
Stars: ✭ 124 (-6.06%)
Mutual labels:  cluster
Doazureparallel
A R package that allows users to submit parallel workloads in Azure
Stars: ✭ 102 (-22.73%)
Mutual labels:  cluster
Miniswarm
Docker Swarm cluster in one command
Stars: ✭ 130 (-1.52%)
Mutual labels:  cluster
Kubernetes Pfsense Controller
Integrate Kubernetes and pfSense
Stars: ✭ 100 (-24.24%)
Mutual labels:  cluster
Icinga2
Icinga is a monitoring system which checks the availability of your network resources, notifies users of outages, and generates performance data for reporting.
Stars: ✭ 1,670 (+1165.15%)
Mutual labels:  cluster
Kubicorn
kubicorn is a free and open source project that solves the Kubernetes infrastructure problem and gives users a rich golang library to work with infrastructure.
Stars: ✭ 1,671 (+1165.91%)
Mutual labels:  cluster
Coinboot
A framework for diskless computing
Stars: ✭ 131 (-0.76%)
Mutual labels:  cluster
Flareclusterlayer
ArcGIS javascript custom graphics layer. Create clusters...with flares.
Stars: ✭ 125 (-5.3%)
Mutual labels:  cluster

clusterhub

An attempt at giving multi process node programs a simple and efficient way to share data.

Build Status Dependency Status codecov

Usage

const cluster = require('cluster');
const numCPUs = require('os').cpus().length;
const hub = require('clusterhub');

if (cluster.isMaster) {
  // Fork workers.
  for (let i = 0; i < numCPUs; i++) {
    cluster.fork();
  }

} else {
  hub.on('event', (data) => {
    // do something with `data`
  });

  // emit event to all workers
  hub.emit('event', { foo: 'bar' });
}

Features

  • Efficient event emitter system. Clusterhub will not send an event to a process that isn't listening for it. Events from the same process of a listener will be emitted synchronously.
  • In process database. Each hub has its own instance of a redis-like database powered by EventVat.

Motive

Node.js is a perfect candidate to developing Date Intensive Real-time Applications. Load balancing in these applications can become complicated when having to share data between processes.

A remote database can be an easy solution for this, but it's not the most optimal. Communicating with a local process is several times faster than opening remote requests from a database. And even if the database is hosted locally, the overhead of communicating with yet another program is lessened.

Note that this module is experimental. It currently works by using a process's internal messaging system.

Made with Clusterhub

API

hub.createHub(id)

Clusterhub already comes with a default global hub. But you can use this if you want to create more.

Hub#destroy()

Call to disable hub from emitting and receiving remote messages/commands.

Additionally, all functions from the regular EventEmitter are included. Plus a couple of extras.

Hub#emitLocal(event, ...args)

Emit an event only to the current process.

Hub#emitRemote(event, ...args)

Emit an event only to other worker processes and master. Or only to workers if the current process is the master.

hub.on('remotehello', () => {
  // Hello from another process.
});

hub.emitRemote('remotehello', { hello: 'there' });

All functions from EventVat are included as well. Their returned value can be accessed by providing a callback as the last argument. Or optionally by its returned value if called by the master.

worker process

hub.set('foo', 'bar', () => {
  hub.get('foo', (val) => {
    console.log(val === 'bar'); // true
  });
});

master process

let returnedVal = hub.incr('foo', (val) => {
  // Can be given a callback for consistency.
  console.log(val === 1); // true
});

// But since it's the master process it has direct access to the database.
console.log(returnedVal === 1); // true

Install

npm install clusterhub

Tests

Tests are written with mocha

npm test
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].