Cantor

Introduction

Cantor is a global sequence generator service, which is distributed, stateless and high available.

Cantor generates unique, relatively orderly and inverse decodable 64-bit integer IDs.

This project provides a easy way to use it in your docker environment. In fact, you can only use a few commands to start up all the components the service depends on and the tools, such like monitors and load testing.

This project contains several components:

Protocol of ID

1 bit 2 bit 2 bit 7 bit 3 bit 28 bit 21 bit
Sign bit as 0, never used Protocol version, supporting 4 versions most Generation sources descriptor, 4 in most Custom spaces, 128 spaces most Cantor service instance number, supporting 4 instances online most Timestamp, which can be used in 8 years from 2018-01-01 00:00:00 Sequence, about 13k ids generated per seconds

In short, Cantor service guarantees that all unique IDs are generated based on its logic clock and a persistent sequence consuming state. When persistence service is down, Cantor service can downgrade to generate ID in local.

User guide

All components are dockerized and we can starts up all the components by docker-compose.

Deployment demonstration:

Service RESTful API:

API HTTP Method Parameters Request example Return
/id GET cate: Custom category, range: How many IDs do you want return in a batch http://localhost:8080/id?cate=0&range=100 {"start": "18446744073709551616", "range":"100"}
/info GET id: The ID to decode http://127.0.0.1:8080/info?id=36313111556915201 {"sequence": 1,"descriptor": 1,"category": 2,"timestamp": 21664133}

SDK

A Java SDK to improve the productivity of interacting with Cantor service.

Monitoring

Monitoring by jmxtrans & influxdb & grafana

Monitoring

Performance Test

Uses apache-jmeter as performance test client. Jmeter version: apache-jmeter-4.0.