Giter Site home page Giter Site logo

node-round-robin-database's Introduction

round-robin-database

In-memory Round Robin Database implementation for storing time-series data. It's pertty much the same as whisper.

Usage

var rrd = require('round-robin-database')
var DB = rrd.DB;
var Layer = rrd.Layer;

var db = new DB({
  layers: [
    new Layer('15s', '1w'), // 15s resolution for a week
    new Layer('1m', '3w'),  // 1m resolution for 3 weeks
    new Layer('1h', '5y')   // 1h resolution for 5 years
  ]
});

console.log(db.getSize()); // 914880, less than 1MB!

// ...

db.write(time, value);

Under the Hood

Data is stored in a single Buffer, which holds {time,value} pairs, every point has a size of 8 bytes (32 bit timestamp, 32 bit float value).

If you wan to store 15s precision values for a week, 1m precision values for 3 weeks, 1h precision values for 5 years, the Buffers size will be (7*24*3600/15+21*24*3600/60+5*365*24*3600/3600)*8/1024 = 893KB. That's pretty good.

On my 3 year old laptop (i5-m450) ~30 records/ms can be written.

License

MIT

node-round-robin-database's People

Contributors

madbence avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

sponnet zig1375

node-round-robin-database's Issues

Handle old records

Old records = older than the retention of the highest precision layer.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.