Twitter's Snowflake: A distributed time-based unique ID ...
文章推薦指數: 80 %
Twitter's Snowflake: A distributed time-based unique ID generator - GitHub - jtejido/snowflake: Twitter's Snowflake: A distributed time-based unique ID ... Skiptocontent {{message}} jtejido / snowflake Public Notifications Fork 0 Star 0 Twitter'sSnowflake:Adistributedtime-baseduniqueIDgenerator License Viewlicense 0 stars 0 forks Star Notifications Code Issues 0 Pullrequests 0 Actions Projects 0 Wiki Security Insights More Code Issues Pullrequests Actions Projects Wiki Security Insights Thiscommitdoesnotbelongtoanybranchonthisrepository,andmaybelongtoaforkoutsideoftherepository. master Branches Tags Couldnotloadbranches Nothingtoshow {{refName}} default Couldnotloadtags Nothingtoshow {{refName}} default 1 branch 0 tags Code Latestcommit Gitstats 8 commits Files Permalink Failedtoloadlatestcommitinformation. Type Name Latestcommitmessage Committime multi single .travis.yml LICENSE README.md snowflake.go utils.go utils_test.go Viewcode Snowflake FromtheirREADME: Motivation Requirements Performance Uncoordinated (Roughly)TimeOrdered DirectlySortable Compact HighlyAvailable Solution SystemClockDependency README.md Snowflake Twitter'sSnowflake:Atime-baseduniqueIDgenerationalgorithmportedtoGolang Thisdoesn'timplementaserver,justthealgorithm. FromtheirREADME: SnowflakeisanetworkserviceforgeneratinguniqueIDnumbersathighscalewithsomesimpleguarantees. Motivation AsweatTwittermoveawayfromMysqltowardsCassandra,we'veneededanewwaytogenerateidnumbers.ThereisnosequentialidgenerationfacilityinCassandra,norshouldtherebe. Requirements Performance minimum10kidspersecondperprocess responserate2ms(plusnetworklatency) Uncoordinated Forhighavailabilitywithinandacrossdatacenters,machinesgeneratingidsshouldnothavetocoordinatewitheachother. (Roughly)TimeOrdered WehaveanumberofAPIresourcesthatassumeanordering(theyletyoulookthingsup"sincethisid"). However,asaresultofalargenumberofasynchronousoperations,wealreadydon'tguaranteein-orderdelivery. Wecanguarantee,however,thattheidnumberswillbek-sorted(references:http://portal.acm.org/citation.cfm?id=70413.70419andhttp://portal.acm.org/citation.cfm?id=110778.110783)withinareasonablebound(we'repromising1s,butshootingfor10'sofms). DirectlySortable Theidsshouldbesortablewithoutloadingthefullobjectsthattherepresent.Thissortingshouldbetheaboveordering. Compact Therearemanyotherwisereasonablesolutionstothisproblemthatrequire128bitnumbers.Forvariousreasons,weneedtokeepouridsunder64bits. HighlyAvailable Theidgenerationschemeshouldbeatleastasavailableasourrelatedservices(likeourstorageservices). Solution ThriftServerwritteninScala idiscomposedof: time-41bits(millisecondprecisionw/acustomepochgivesus69years) configuredmachineid-10bits-givesusupto1024machines sequencenumber-12bits-rollsoverevery4096permachine(withprotectiontoavoidrolloverinthesamems) SystemClockDependency YoushoulduseNTPtokeepyoursystemclockaccurate.Snowflakeprotectsfromnon-monotonicclocks,i.e.clocksthatrunbackwards.IfyourclockisrunningfastandNTPtellsittorepeatafewmilliseconds,snowflakewillrefusetogenerateidsuntilatimethatisafterthelasttimewegeneratedanid.Evenbetter,runinamodewherentpwon'tmovetheclockbackwards.Seehttp://wiki.dovecot.org/TimeMovedBackwards#Time_synchronizationfortipsonhowtodothis. About Twitter'sSnowflake:Adistributedtime-baseduniqueIDgenerator Topics id-generation id-generator snowflake-twitter Resources Readme License Viewlicense Stars 0 stars Watchers 2 watching Forks 0 forks Releases Noreleasespublished Packages0 Nopackagespublished Languages Go 100.0% Youcan’tperformthatactionatthistime. Yousignedinwithanothertaborwindow.Reloadtorefreshyoursession. Yousignedoutinanothertaborwindow.Reloadtorefreshyoursession.
延伸文章資訊
- 1sony/sonyflake: A distributed unique ID generator ... - GitHub
Sonyflake is a distributed unique ID generator inspired by Twitter's Snowflake. Sonyflake focuses...
- 2Twitter's Snowflake: A distributed time-based unique ID ...
Twitter's Snowflake: A distributed time-based unique ID generator - GitHub - jtejido/snowflake: T...
- 3Snowflake ID - Wikipedia
- 4System Design Interview: Scalable Unique ID Generator (Twitter ...
- 5A .NET port of Twitter Snowflake ID generation algorithm.
移植 Snowflake 的 ID 生成算法。有关该算法的详情,请参阅. /// https://github.com/twitter/snowflake/tree/snowflake-2010...