{"id":23440075,"url":"https://github.com/mumrah/flake-java","last_synced_at":"2025-09-07T01:07:03.177Z","repository":{"id":2250402,"uuid":"3205397","full_name":"mumrah/flake-java","owner":"mumrah","description":"Id generator based on Twitter's Snowflake","archived":false,"fork":false,"pushed_at":"2013-09-08T20:38:29.000Z","size":112,"stargazers_count":104,"open_issues_count":1,"forks_count":39,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-04-13T08:09:55.148Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mumrah.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-01-18T02:32:56.000Z","updated_at":"2024-11-20T03:17:13.000Z","dependencies_parsed_at":"2022-08-18T01:55:50.106Z","dependency_job_id":null,"html_url":"https://github.com/mumrah/flake-java","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mumrah%2Fflake-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mumrah%2Fflake-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mumrah%2Fflake-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mumrah%2Fflake-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mumrah","download_url":"https://codeload.github.com/mumrah/flake-java/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248681491,"owners_count":21144700,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-23T15:40:13.497Z","updated_at":"2025-04-13T08:10:13.630Z","avatar_url":"https://github.com/mumrah.png","language":"Java","funding_links":[],"categories":["分布式开发"],"sub_categories":["Spring Cloud框架"],"readme":"# Unique Id generator\n\nBased on http://blog.boundary.com/2012/01/12/Flake-A-decentralized-k-ordered-id-generation-service-in-Erlang.html\nwhich is in turn based on Twitter's Snowflake project: http://engineering.twitter.com/2010/06/announcing-snowflake.html\n\nGenerates unique ids based on the current epoch time, current machine identity,\nand a counter. The result are mostly ordered unique ids that require no\nsynchronization between machines.\n\n\n# Compile and run\n\n    javac -cp .:./lib/uuid-3.2.1-SNAPSHOT.jar:./lib/commons-codec-1.6.jar src/uniq/UniqueId.java\n    java -cp .:./lib/uuid-3.2.1-SNAPSHOT.jar:./lib/commons-codec-1.6.jar:src uniq.UniqueId\n\n# Performance\n\n2011 MacBook Pro, 2.8Ghz i7\n\n## Cat to file\n\n    $ time java -cp .:./lib/uuid-3.2.1-SNAPSHOT.jar:./lib/commons-codec-1.6.jar:src uniq.UniqueId 10000000 \u003e out\n    \n    real    0m18.498s\n    user    0m5.662s\n    sys     0m12.973s\n\n    $ ls -lh out\n    -rw-r--r--  1 mumrah  staff   153M May 22 10:52 out\n\n540 id/ms\n\nSince each id is 128 bits, the I/O rate comes out to 8640000 bytes per second, or 8.24 MB/s.\nCompare this to 66.59 MB/s which is the speed that the same system can \"yes \u003e omgyes\". I guess that order of\nmagnitude difference is the price of safety/synchronization.\n\n## Pipe to /dev/null\n\n    $ time java -cp .:./lib/uuid-3.2.1-SNAPSHOT.jar:./lib/commons-codec-1.6.jar:src uniq.UniqueId 10000000 \u003e /dev/null\n\n    real    0m7.794s\n    user    0m4.688s\n    sys     0m3.253s\n\n1280 id/ms\n\n## Pipe to fifo, fifo to /dev/null\n\n    $ time java -cp .:./lib/uuid-3.2.1-SNAPSHOT.jar:./lib/commons-codec-1.6.jar:src uniq.UniqueId 10000000 \u003e foo\n\n    real    0m18.051s\n    user    0m5.594s\n    sys     0m12.594s\n\n554 id/ms\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmumrah%2Fflake-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmumrah%2Fflake-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmumrah%2Fflake-java/lists"}