TobiaszCudnik / demo-distributed-heartbeat

Demo of a distributed heartbeat service

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Distributed Heartbeat (demo)

Distributed heartbeat microservice with a scalable Redis Sentinel backend. Supports groups and garbage collection. Spec from UB.io. DB dockers from zaozaoniao.

API

  • GET /
  • GET /:group
  • POST /:group/:id
  • DELETE /:group/:id

Features

  • groups with counters
  • garbage collection
  • granular heartbeat updates (main traffic)
  • scaling up by adding new nodes
  • redis sentinel for DB scaling
    • more masters for sharding
    • more slaves for replication
  • granular per-group write locks
  • groups index write lock

Usage

  • yarn install
  • yarn build
  • yarn start:db
  • yarn start

Tests

  • yarn start:db
  • yarn test

Dependencies

  • node
  • yarn
  • docker-compose

Config

  • ./config.ts
  • MAX_AGE env var

TODO

  • unit tests (-network, +mocks)
  • better exceptions handling
  • authentication
  • request data validation
  • CORS
  • sourcemaps in stacktraces
  • persisting redis for fault tolerance
  • pipeline to batch DB requests
  • docker-compose to Kubernetes (with Kompose)
  • pm2 / nodemon / ...
  • pub/sub based mutexes (instead of timeout-based)
  • stream JSON in a workerpool (for lists)
  • TypeORM?

About

Demo of a distributed heartbeat service


Languages

Language:TypeScript 97.5%Language:Dockerfile 1.3%Language:Shell 1.0%Language:JavaScript 0.3%