All Projects → imqueue → core

imqueue / core

Licence: ISC license
Simple JSON-based messaging queue for inter service communication

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to core

orkid-node
Reliable and modern Redis Streams based task queue for Node.js 🤖
Stars: ✭ 61 (+117.86%)
Mutual labels:  message-queue, redis-queue
rpc
RPC-like client-service implementation over messaging queue
Stars: ✭ 26 (-7.14%)
Mutual labels:  message-queue, redis-queue
hanbo-db
hanboDB is a high available,low latency memory database system
Stars: ✭ 29 (+3.57%)
Mutual labels:  redis-server, message-queue
cli
Command Line Interface for @imqueue
Stars: ✭ 20 (-28.57%)
Mutual labels:  message-queue, redis-queue
sessionx
Go's web session library.
Stars: ✭ 75 (+167.86%)
Mutual labels:  redis-server
redis-developer.github.io
The Home of Redis Developers
Stars: ✭ 28 (+0%)
Mutual labels:  redis-server
cachegrand
cachegrand is an open-source fast, scalable and secure Key-Value store, also fully compatible with Redis protocol, designed from the ground up to take advantage of modern hardware vertical scalability, able to provide better performance and a larger cache at lower cost, without losing focus on distributed systems.
Stars: ✭ 87 (+210.71%)
Mutual labels:  redis-server
Redis-Windows-32bit
The Windows 64-bit/32-bit bin files for Redis can download there
Stars: ✭ 53 (+89.29%)
Mutual labels:  redis-server
qless-php
PHP Bindings for qless
Stars: ✭ 25 (-10.71%)
Mutual labels:  redis-queue
microq
Micro job queue built on mongo
Stars: ✭ 67 (+139.29%)
Mutual labels:  message-queue
redface
RedFace means redis interface.
Stars: ✭ 23 (-17.86%)
Mutual labels:  redis-server
coronamq
The simplest way to implement a task queue with Java, Vertx and PostgreSQL.
Stars: ✭ 23 (-17.86%)
Mutual labels:  message-queue
terraform-aws-elasticache
Terraform module to create Elasticache Cluster and replica for Redis and Memcache.
Stars: ✭ 19 (-32.14%)
Mutual labels:  redis-server
CRDT-Redis
CRDTs implemented in Redis
Stars: ✭ 35 (+25%)
Mutual labels:  redis-server
iris
Lightweight Component Model and Messaging Framework based on ØMQ
Stars: ✭ 50 (+78.57%)
Mutual labels:  message-queue
rancher-redis
A containerized redis master/slave configuration with sentinels for use in Rancher
Stars: ✭ 13 (-53.57%)
Mutual labels:  redis-server
SPSC Queue
A highly optimized single producer single consumer message queue C++ template
Stars: ✭ 185 (+560.71%)
Mutual labels:  message-queue
keva
Low-latency in-memory key-value store, Redis drop-in alternative
Stars: ✭ 76 (+171.43%)
Mutual labels:  redis-server
phpRedisTimeSeries
📈 Use Redis Time Series in PHP!
Stars: ✭ 23 (-17.86%)
Mutual labels:  redis-server
redis
Redis server written in Go / Golang (prototype)
Stars: ✭ 53 (+89.29%)
Mutual labels:  redis-server

I Message Queue (@imqueue/core)

Build Status codebeat badge Coverage Status Known Vulnerabilities License

Simple JSON-based messaging queue for inter service communication

Related packages:

  • @imqueue/rpc - RPC-like client/service implementation over @imqueue/core.
  • @imqueue/cli - Command Line Interface for imqueue.

Features

With current implementation on RedisQueue:

  • Fast unwarranted message delivery (if consumer grab the message and dies message will be lost). Up to ~35-40k of 1Kb messages per second on i7 core by benchmarks.
  • Fast warranted message delivery (only 1.5-2 times slower than unwarranted). If consumer grab a message and dies it will be re-scheduled in queue. Up to ~20-25K of 1Kb messages per second on i7 core by benchmarks.
  • No timers or constant redis polling used for implementation, as result - no delays in delivery and low CPU usage on application workers. When idling it does not consume resources!
  • Supports gzip compression for messages (decrease traffic usage, but slower).
  • Concurrent workers model supported, the same queue can have multiple consumers.
  • Delayed messages supported, fast as ~10K of 1Kb messages per second on i7 core by benchmarks.
  • Safe predictable scaling of queues. Scaling number of workers does not influence traffic usage.
  • Round-robin message balancing between several redis instances. This allows easy messaging queue redis horizontal scaling.
  • TypeScript included!

Requirements

Currently this module have only one available adapter which is Redis server related. So redis-server > 3.8+ is required.

If config command is disabled on redis it will be required to turn on manually keyspace notification events (actual on use with ElasticCache on AWS), like:

notify-keyspace-events Ex

Further, more adapters will be added... if needed.

Install

npm i --save @imqueue/core

Usage

import IMQ, { IMessageQueue, IJson } from '@imqueue/core';

(async () => {
    const queueOne: IMessageQueue = IMQ.create('QueueOne');
    const queueTwo: IMessageQueue = IMQ.create('QueueTwo');

    // start queues
    await queueOne.start();
    await queueTwo.start();

    // handle queue messages
    queueOne.on('message', (message: IJson, id: string, fromQueue: string) => {
        console.log('queueOne message received:', message, id, fromQueue);

        if (message.delay) {
            queueOne.destroy();
            queueTwo.destroy();
        }
    });
    queueTwo.on('message', (message: IJson, id: string, fromQueue: string) => {
        console.log('queueTwo message received:', message, id, fromQueue);
    });

    // sending queue messages
    await queueOne.send('QueueTwo', { hello: 'two' });
    await queueTwo.send('QueueOne', { hello: 'one' });

    // sending delayed messages
    const delay = 1000;
    await queueOne.send('QueueOne', { delay }, delay);
})();

Benchmarking

First of all make sure redis-server is running on the localhost. Current version of benchmark supposed to have redis running localhost because it is going to measure it's CPU usage stats.

All workers during benchmark test will have their dedicated CPU affinity to make sure collected stats as accurate as possible.

git clone [email protected]:Mikhus/core.git
cd imq
node benchmark -c 4 -m 10000

Other possible benchmark options:

node benchmark -h                                   
Options:
  --version                     Show version number                    [boolean]
  -h, --help                    Show help                              [boolean]
  -c, --children                Number of children test process to fork
  -d, --delay                   Number of milliseconds to delay message delivery
                                for delayed messages. By default delayed
                                messages is of and this argument is equal to 0.
  -m, --messages                Number of messages to be sent by a child process
                                during test execution.
  -z, --gzip                    Use gzip for message encoding/decoding.[boolean]
  -s, --safe                    Use safe (guaranteed) message delivery
                                algorithm.                             [boolean]
  -e, --example-message         Path to a file containing JSON of example
                                message to use during the tests.
  -p, --port                    Redis server port to connect to.
  -t, --message-multiply-times  Increase sample message data given number of
                                times.

Number of child workers running message queues are limited to a max number of CPU in the system -2. First one, which is CPU0 is reserved for OS tasks and for stats collector process. Second, which is CPU1 is dedicated to redis process running on a local machine, All others are safe to run queue workers.

For example, if there is 8 cores on a machine it is safe to run up to 6 workers. For 4-core machine this number is limited to 2. If there is less cores results will not give good visibility of load.

NOTE: paragraphs above this note are Linux-only related! On MacOS there is no good way to set process affinity to a CPU core, Windows support is not tested and is missing for the moment in benchmarking. I does not mean benchmark will not work on Mac & Win but the results won't be accurate and predictable.

Running Unit Tests

git clone [email protected]:imqueue/core.git
cd imq
npm test

License

ISC

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].