Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Java
  3. CosId

CosId

Apache-2.0Javav3.1.0

A universal, flexible, and high-performance distributed ID generator for Java applications.

Visit WebsiteGitHubGitHub
634 stars86 forks0 contributors

What is CosId?

CosId is a Java-based distributed ID generator that provides multiple algorithms like SnowflakeId and SegmentChainId for high-performance, scalable ID generation. It solves common issues such as machine ID allocation, clock backwards problems, and integrates seamlessly with databases and sharding frameworks.

Target Audience

Java developers building distributed systems, microservices, or applications requiring scalable and unique identifier generation, especially those using Spring Boot, ShardingSphere, or MyBatis.

Value Proposition

Developers choose CosId for its exceptional performance (up to 127 million ops/s), flexibility in algorithm choice, and out-of-the-box integrations with popular Java ecosystems like ShardingSphere and MyBatis.

Overview

Universal, flexible, high-performance distributed ID generator. | 通用、灵活、高性能的分布式 ID 生成器

Use Cases

Best For

  • Generating unique IDs in high-throughput microservices
  • Sharding databases with time-based or modulo strategies
  • Integrating ID generation with MyBatis for automatic entity population
  • Deploying in Kubernetes environments with StatefulSet machine ID allocation
  • Avoiding clock synchronization issues in distributed Snowflake ID implementations
  • Applications needing both standalone and distributed ID generation options

Not Ideal For

  • Projects not using the JVM ecosystem (e.g., Node.js or Python applications)
  • Simple applications where UUID or database auto-increment suffices without distributed needs
  • Teams unwilling to manage external dependencies like Redis or ZooKeeper for ID distribution
  • Environments with strict resource constraints where prefetch workers' overhead is prohibitive

Pros & Cons

Pros

Blazing Fast Performance

SegmentChainId achieves ~127 million ops/s in JMH benchmarks, making it one of the fastest Java ID generators available for high-throughput systems.

Flexible Algorithm Choice

Offers multiple algorithms like SnowflakeId with configurable bit allocation and SegmentChainId for lock-free performance, catering to different scalability needs.

Seamless Framework Integrations

Provides plugins for ShardingSphere (e.g., COSID_INTERVAL sharding) and MyBatis for automatic ID generation, reducing boilerplate code in Java applications.

Robust Clock Handling

Includes ClockBackwardsSynchronizer to mitigate SnowflakeId clock issues with configurable thresholds, improving reliability in distributed environments.

Cons

Infrastructure Dependencies

Relies on external systems like Redis, JDBC databases, or ZooKeeper for machine ID and segment distribution, adding deployment and maintenance overhead.

Complex Configuration

The extensive YAML configuration with numerous tunable parameters (e.g., safe distance, prefetch period) can be overwhelming and error-prone for new users.

Spring Boot Version Lock-in

Different CosId versions are tightly coupled to specific Spring Boot releases (e.g., v2.x for Spring Boot 3.x), complicating upgrades and compatibility.

Frequently Asked Questions

Quick Stats

Stars634
Forks86
Contributors0
Open Issues8
Last commit7 days ago
CreatedSince 2021

Tags

#generator#java-library#distributed#high-performance#redis#kubernetes#id#k8s#id-generator#jdbc#spring-boot#snowflake#mybatis#database-sharding#cloud-native

Built With

M
MySQL
M
MyBatis
M
MongoDB
S
Spring Boot
Z
Zookeeper
J
Java
R
Redis

Links & Resources

Website

Included in

Java47.5k
Auto-fetched 10 hours ago

Related Projects

RedissonRedisson

Redisson: Valkey & Redis Java Client and Real-Time Data Platform. Sync/Async/RxJava/Reactive API. Over 50 Valkey and Redis based Java objects and services: Set, Multimap, SortedSet, Map, List, Queue, Deque, Semaphore, Lock, AtomicLong, Map Reduce, Bloom filter, Spring, Tomcat, Scheduler, JCache API, Hibernate, RPC, local cache..

Stars24,366
Forks5,485
Last commit20 hours ago
HikariCPHikariCP

光 HikariCP・A solid, high-performance, JDBC connection pool at last.

Stars21,133
Forks3,007
Last commit17 days ago
ShardingSphereShardingSphere

Empowering Data Intelligence with Distributed SQL for Sharding, Scalability, and Security Across All Databases.

Stars20,747
Forks6,892
Last commit20 hours ago
QuestDBQuestDB

QuestDB is a high performance, open-source, time-series database

Stars17,157
Forks1,616
Last commit14 hours ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub