This project is read-only.


FlakeGen.Id64Generator generates compact, directly sortable, 64-bit ids.

The generator can get it's unique number. There are two possible ways of assigning a unique number to the generator:
  • By specifying data centre id as well as generator id. Both data centre id as well as generator id are 5 bits long. That gives 32 unique data centres as 32 unique generators in each data centre. 1024 unique instances altogether.
  • By specifying only generator id. This is good scenario if there are many generators running on a single box. In that case generator id can be 10 bit long which gives 1024 unique instances.


namespace FlakeGenConsole
    public class Program
        public static void Main(string[] args)
            //gets default data centre id (0) and default generator id (0)
            var id64Generator = new Id64Generator();
            Console.WriteLine("1 : {0}", id64Generator.GenerateId());

            // generator id: 12 in data centre id: 30
            var idGenerator2 = new Id64Generator(12, 30);
            Console.WriteLine("2 : {0}", idGenerator2.GenerateId());


1: 2926779522088960
2: 2928394186571776

Last edited Nov 8, 2012 at 12:34 PM by tompawlak, version 3


No comments yet.