ZeroREST
Build microservices with ZeroMQ.
Provides familiar express-style API as an abstraction of 0mq request-reply sockets for building REST-like microservices.
Installation
You will need ZeroMQ installed: Get ZeroMQ
npm install zerorest
Benchmarks
ZeroREST
- 50k concurrent requests
- 3859.51 requests/sec
- 0.2591 ms/request
Raw Node.js HTTP
- 10k concurrent requests
- 1247.66 requests/sec
- 0.8015 ms/request
See for yourself...
In the repo, you will find some convenient shell scripts for running benchmarks on your local machine.
Setup
git clone git@github.com:chuej/zerorestcd zerorest
ZeroREST
./bin/benchmark-zerorest
OR
docker-compose run --rm service ./bin/benchmark-zerorest
HTTP
./bin/benchmark-http
OR
docker-compose run --rm service ./bin/benchmark-http
Quickstart
Service:
var ZR; ZR = ; var users zms;zms = "tcp://0.0.0.0:5555"; users = zms;users;zmsstart
Client:
var Client client; Client = Client; client = "tcp://0.0.0.0:5555"; client;
Examples
Examples are located in the github repo:
git clone git://github.com/chuej/zerorest.gitcd zerorestnpm install
Docker / Docker Compose
The following command will start the example service, then the client.
docker-compose up
sh scripts
Service:
./bin/example-service
Client:
./bin/example-client
Usage
var ZR startService; ZR = ; { var templates users zms; conf = broker: concurrency: 5 // number of concurrent router sockets hearbeat: 2500 lbmode: 'rr' // load-balance mode: round-robin (rr) or random (rand) worker: concurrency: 5 // number of concurrent dealer sockets per route reconnect: 1000 heartbeat: 2500 noFork: false // by default, zerorest will fork processes for brokers/workers url: "tcp://0.0.0.0:5555" ; zms = "tcp://0.0.0.0:5555"; // or zms = conf; zms; // array of middleware zms; conf = reconnect: 1000 heartbeat: 2500 path: "/users" ; users = zms; // or users = zms; users; users; users; users; templates = zms; templates; zms; zms; return zmsstart;}; ;
var Client client; Client = Client; client = "tcp://0.0.0.0:5555"; client;
Tests
Running the test suite is as simple as cloning the repo and running npm test
.
git clone git://github.com/chuej/zerorest.gitcd zerorestnpm installnpm test