GET - /api/v1/new
Description: Gets a new 64 bit UUID
Inputs: None
Output: Number (length = 64)
Defining the system data model early on will clarify how data will flow among different components of the system. Also you could draw an ER diagram using the diagramming tool to enhance your design...
DNS: Geo based Routing to scale across datacenter
LoadBalancer: To route traffic to healthy nodes. Also, we use LoadBalancer to scale and de-scale nodes in a datacenter
Distributed UUID generator: Snowflake ID Approach
Algorithm:
Choice is twitter Snowflake:
We will use Twitter snowflake because this is very efficient essentially it store 1st bit for future purposes, 41 bits for timestamp in milliseconds since epoch (unix or custom), 5 bits for datacenter id, 5 bits for machine id, 2 bits sequence number (every id generated on a machine is incremented by 1 generated every millisecond). With our approach we don't need additional storage, neither we do have synchronisation issues
GEOROUTING:
We will use GEO Routing to cater datacenter level scaling. For instance client in us-west-1a will get routed to a load balancer that routes to machines in us-west-1a. This way we can route to the closest datacenter to the user.
Monitoring and Alerting
Alternatives
Our approach depends on Clock and we could expect clock skew. To address that, we will need NTP setup i.e. to ensure all machines have the time in-sync. I think we should config our machines using configuration management tools such as Ansible
With our approach we can add and remove nodes are we want. however, when a node is removed the calculations would change. So, if we want to have audit trail at later point. This many be an issue
I think we can look at the improvements in algorithm and given our specific needs we may need to tweak the UID length and how we configure our UID for example: Mastodon uses 48 bits and 32 bits for timestamp.