High performance unique number generator powered by Go

SEQSVR

High performance unique number generator powered by Go

中文 README

Features

  • Distributed: Can be scaled horizontally
  • High performance: Allocation ID only accesses memory (up to the upper limit will request the database once)
  • Ease of use: Provide as HTTP service
  • Unique: MySQL auto increment ID, never repeat

Requirement

We are using these awesome projects as necessary libraries.

  • gopkg.in/yaml.v2
  • github.com/go-sql-driver/mysql
  • github.com/satori/go.uuid

Installation

You can install this service in the following three ways.

Note: You need to create the database and modify the configuration of the database in the configuration file before starting.

go get:

go get github.com/qichengzx/seqsvr
seqsvr

Compile By Yourself:

git clone [email protected]:qichengzx/seqsvr.git
cd seqsvr
go build .
./seqsvr

Docker:

The Docker "multi-stage" build feature is used, be ensure the Docker version is 17.05 or above. See:Use multi-stage builds

git clone [email protected]:qichengzx/seqsvr.git
cd seqsvr
docker build -t seqsvr:latest .
docker run -p 8000:8000 seqsvr:latest

Create Database

The database name can be customized, modify config.yml.

Then import the following SQL to generate the data table.

CREATE TABLE `generator_table` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `uuid` char(36) NOT NULL COMMENT 'Machine identification',
  PRIMARY KEY (`id`),
  UNIQUE KEY `id_UNIQUE` (`id`),
  UNIQUE KEY `stub_UNIQUE` (`uuid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

Configuration

The configuration file is using YAML.

#app
port: ':8000'

#service
step: 100

#db
mysql:
  user: 'root'
  password: ''
  host: 'tcp(localhost:3306)'
  database: 'sequence'

Usage

curl http://localhost:8000/new

{"code":0,"msg":"ok","data":{"id":101}}
Owner
xin zhao
Web developer, useing PHP, Go.
xin zhao
Similar Resources

🔑A high performance Key/Value store written in Go with a predictable read/write performance and high throughput. Uses a Bitcask on-disk layout (LSM+WAL) similar to Riak.

bitcask A high performance Key/Value store written in Go with a predictable read/write performance and high throughput. Uses a Bitcask on-disk layout

Sep 26, 2022

the pluto is a gateway new time, high performance, high stable, high availability, easy to use

pluto the pluto is a gateway new time, high performance, high stable, high availability, easy to use Acknowledgments thanks nbio for providing low lev

Sep 19, 2021

A high performance NoSQL Database Server powered by Go

A high performance NoSQL Database Server powered by Go

LedisDB Ledisdb is a high-performance NoSQL database library and server written in Go. It's similar to Redis but store data in disk. It supports many

Dec 26, 2022

Goproxy4mysql - Kingshard- a high-performance proxy for MySQL powered by Go

kingshard 中文主页 Fork from github.com/flike/kingshard Overview kingshard is a high

Jan 7, 2022

PiHex Library, written in Go, generates a hexadecimal number sequence in the number Pi in the range from 0 to 10,000,000.

PiHex PiHex Library generates a hexadecimal number sequence in the number Pi in the range from 0 to 1.0e10000000. To calculate using "Bailey-Borwein-P

Nov 18, 2022

A simple command line tool using which you can skip phone number based SMS verification by using a temporary phone number that acts like a proxy.

A simple command line tool using which you can skip phone number based SMS verification by using a temporary phone number that acts like a proxy.

Fake-SMS A simple command line tool using which you can skip phone number based SMS verification by using a temporary phone number that acts like a pr

Dec 31, 2022

MNA - stands for mobile number assignment - a small zero external dependency golang library that is used to identify mobile number assignment in tanzania

MNA - stands for mobile number assignment - a small zero external dependency golang library that is used to identify mobile number assignment in tanzania

Nov 29, 2021

A tool to determine the highest version number that's smaller than a target version number

semver-highest A tool to determine the highest version number that's smaller than a target version number. Installation go install github.com/marten-s

Oct 13, 2021

A simple command line tool using which you can skip phone number based SMS verification by using a temporary phone number that acts like a proxy

A simple command line tool using which you can skip phone number based SMS verification by using a temporary phone number that acts like a proxy

Fake-SMS A simple command line tool using which you can skip phone number based SMS verification by using a temporary phone number that acts like a pr

Dec 31, 2022

Converts a number to its English counterpart. Uses arbitrary precision; so a number of any size can be converted.

Converts a number to its English counterpart. Uses arbitrary precision; so a number of any size can be converted.

Dec 14, 2021

Iran National Id, Bank Card Number, Mobile Number Validator for golang

Iran IDValidator Iran National Id, Bank Card Number, Mobile Number Validator for golang Installation go get -u github.com/mohammadv184/idvalidator Us

Dec 20, 2021

Divide (distribute) the given number (n) into number (p) of parts randomly,

Number Split Randomly The sample code written in Go lang Executables This repo already have executables for Linux and windows, after clone the repo ju

Feb 4, 2022

Using NFP (Number Format Parser) you can get an Abstract Syntax Tree (AST) from Excel number format expression

NFP (Number Format Parser) Using NFP (Number Format Parser) you can get an Abstract Syntax Tree (AST) from Excel number format expression. Installatio

Feb 4, 2022

Toy project to test golang toolset, using as pretext the "cyclic number" problem (famous 142857 number)

go-cyclic-number Toy project to test golang toolset, using as pretext the "cyclic number" problem (famous 142857 number) First version: https://github

Feb 12, 2022

A distributed unique ID generator of using Sonyflake and encoded by Base58

Indigo About A distributed unique ID generator of using Sonyflake and encoded by Base58. ID max length is 11 characters by unsigned int64 max value. A

Nov 24, 2022

A tiny and fast Go unique string generator

Nano ID A tiny and fast Go unique string generator Safe. It uses cryptographically strong random APIs and tests distribution of symbols. Compact. It u

Nov 11, 2022

A distributed unique ID generator inspired by Twitter's Snowflake

Sonyflake is a distributed unique ID generator inspired by Twitter's Snowflake.

Jan 2, 2023

A high performance gin middleware to cache http response. Compared to gin-contrib/cache, It has a huge performance improvement. 高性能gin缓存中间件,相比于官方版本,有明显性能提升。

A high performance gin middleware to cache http response. Compared to gin-contrib/cache, It has a huge performance improvement. 高性能gin缓存中间件,相比于官方版本,有明显性能提升。

A high performance gin middleware to cache http response. Compared to gin-contrib/cache. It has a huge performance improvement.

Dec 28, 2022

go-fastdfs 是一个简单的分布式文件系统(私有云存储),具有无中心、高性能,高可靠,免维护等优点,支持断点续传,分块上传,小文件合并,自动同步,自动修复。Go-fastdfs is a simple distributed file system (private cloud storage), with no center, high performance, high reliability, maintenance free and other advantages, support breakpoint continuation, block upload, small file merge, automatic synchronization, automatic repair.(similar fastdfs).

go-fastdfs 是一个简单的分布式文件系统(私有云存储),具有无中心、高性能,高可靠,免维护等优点,支持断点续传,分块上传,小文件合并,自动同步,自动修复。Go-fastdfs is a simple distributed file system (private cloud storage), with no center, high performance, high reliability, maintenance free and other advantages, support breakpoint continuation, block upload, small file merge, automatic synchronization, automatic repair.(similar fastdfs).

中文 English 愿景:为用户提供最简单、可靠、高效的分布式文件系统。 go-fastdfs是一个基于http协议的分布式文件系统,它基于大道至简的设计理念,一切从简设计,使得它的运维及扩展变得更加简单,它具有高性能、高可靠、无中心、免维护等优点。 大家担心的是这么简单的文件系统,靠不靠谱,可不

Jan 8, 2023
Comments
  • Just a toy Case?

    Just a toy Case?

    you should lock before query db. Just think of concurrent get db's returned id and update id segment, the previous one segment may dropped without any use, and if concurrent is large enough, mysql may breakdown.

Compact, sortable and fast unique IDs with embedded metadata.
Compact, sortable and fast unique IDs with embedded metadata.

A spec for unique IDs in distributed systems based on the Snowflake design, i.e. a coordination-based ID variant. It aims to be friendly to both machi

Dec 22, 2022
Universally Unique Lexicographically Sortable Identifier (ULID) in Go

Universally Unique Lexicographically Sortable Identifier A Go port of alizain/ulid with binary format implemented. Background A GUID/UUID can be subop

Jan 9, 2023
✨ Generate unique IDs (Port of Node package "generate-snowflake" to Golang)

✨ Generate Snowflake Generate unique IDs. Inspired by Twitter's Snowflake system. ?? Installation Initialize your project (go mod init example.com/exa

Feb 11, 2022
K-Sortable Globally Unique IDs

ksuid ksuid is an efficient, comprehensive, battle-tested Go library for generating and parsing a specific kind of globally unique identifier called a

Jan 9, 2023
A network service for generating unique ID numbers inspired by Twitter's Snowflake.

Hanabira Hanabira is a network service for generating unique ID numbers inspired by Twitter's Snowflake. How to run hanabira-cluster and etcd-cluster

Jan 13, 2022
❄ An Lock Free ID Generator for Golang based on Snowflake Algorithm (Twitter announced).
❄ An Lock Free ID Generator for Golang based on Snowflake Algorithm (Twitter announced).

❄ An Lock Free ID Generator for Golang based on Snowflake Algorithm (Twitter announced).

Dec 14, 2022
golang实现的分布式唯一ID生成器distributed id generator,有全局趋势递增、严防时钟漂移、高可用、高性能等特点
golang实现的分布式唯一ID生成器distributed id generator,有全局趋势递增、严防时钟漂移、高可用、高性能等特点

ekko-idgenerator是什么 顾名思义,ekko是一个分布式唯一ID生成器,参考了snowFlake思想,但是并不局限于其设计。 名称由来 英雄联盟的时间刺客ekko 特点 易用,最大限度保证系统的易用性,支持Get与MultiGet; 高并发,单机每秒100w个唯一ID生成; 高可用,理

Jan 4, 2023
Snowflake - Simple twitter's snowflake uniquely identifiable descriptors (IDs) format generator for Go

Snowflake Dead simple and fast Twitter's snowflake id generator in Go. Installation go get github.com/HotPotatoC/snowflake Usage Generating a snowflak

Oct 6, 2022
A generator library for concise, unambiguous and URL-safe UUIDs

shortuuid A Go library that generates concise, unambiguous, URL-safe UUIDs. Based on and compatible with the Python library shortuuid. Often, one need

Jan 4, 2023
Guess-number-game - Computer thoughts of some integer number, you must guess it with limited number of attempts
Guess-number-game - Computer thoughts of some integer number, you must guess it with limited number of attempts

Guess number game Rules Computer has thought of some integer number. You must guess it, you have numberOfAttempts attempts. How to run Just type in co

Dec 31, 2021