Multi-master Replication ID Generator

The concept is we have multiple master (let say k masters). For each master we increase the id by k instead of 1.

We can also use the auto_increment feature of the database

Pasted image 20230630233500.png

So for example, in this case we have k = 2:

  • First server we have id = 1, 3, 5
  • Second server we have id = 2, 4, 6

Pros:

  • Easy to do

Cons:

  • Hard to scale with multiple data server
  • IDs do not go up with time across multiple servers
  • Does not scale well when add / remove server