askuzminov / Mitol

Lightweight NodeJS http server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mitol

Lightweight, high performance NodeJS Server.

Build Status Coverity Status


Project description

Project was born out of the need for faster performing server using NodeJS. Current implementation lacks focus on performance, which can be achieved by moving parts of code to native C++ bindings.

Aim of the project is to offer an alternative solution, which is using less memory and CPU power, giving you available resources for your code or handling higher number of requests.


Advantages

  • No changes required: Just replace require('http') with require('mitol')
  • Top Speed: Roughly 3x better performance than integrated server
  • Additional features: Work in progress (Static file server, Router, ...)

Benchmarks

Benchmark


How to use

Currently only Linux has been tested. To install the project make sure you have node-gyp, python and build-tools (GCC, etc.) installed. To build the node package do the following:

npm i mitol

To test the project you can use the following script

(Single process):

const http = require('mitol');
 
let server = http.createServer((req, res) => {
    res.end('Hello World!');
});
 
server.listen(8080, () => {
    console.log('Example app listening on port 8080!')
});

(Multi process):

const cluster = require('cluster');
const numCPUs = require('os').cpus().length;
const http = require('mitol');
 
if (cluster.isMaster) {
    // Fork workers.
    for (let i = 0; i < numCPUs; i++) {
        cluster.fork();
    }
 
    cluster.on('exit', (worker, code, signal) => {
        console.log(`worker ${worker.process.pid} died`);
    });
} else {
    let server = http.createServer((req, res) => {
        res.end('Hello World!');
    });
 
    server.listen(8080, () => {
        console.log('Example app listening on port 8080!')
    });
}

Like the project?

You can support me by donating: https://www.paypal.com/paypalme/helidium


Thanks

My Family and Friends for supporting me!
All the fans for believing in the project!
Leandro A. F. Pereira For his wonderful Lwan project.
Alex Hultman For his wonderful uWebSockets project.
TechEmpower For Server benchmarks.
GitHub For code hosting.
Travis For code testing.
Coverity For code defects check


Copyright (c) 2017 Mitol Project - Released under the Zlib license.

About

Lightweight NodeJS http server

License:Other


Languages

Language:C++ 95.1%Language:Makefile 2.1%Language:Python 1.5%Language:CMake 0.9%Language:JavaScript 0.4%