@greghogg5: Auto-increment IDs cause major challenges when scaling a system across multiple distributed databases. In a single database auto-incrementing a number by one for each new record is simple and consistent. When you distribute the data across multiple servers they can no longer easily coordinate the next number. One solution is to configure each server with a unique starting offset and a fixed increment step. For example with three servers the first starts at one the second at two and the third at three. They all increment by three so the first server generates one four and seven while the second generates two five and eight. This approach works initially but becomes highly complex when you need to add or remove servers. Adding a fourth server requires recalculating the offset and increment step for every single machine in the cluster. Changing these configurations on live databases without causing ID collisions or downtime is incredibly difficult. To avoid this complexity some architectures use a centralized ticket server to hand out IDs. The ticket server acts as a single source of truth that increments a single counter for the entire system. However this centralized ticket server reintroduces a single point of failure into the architecture. It also creates a massive performance bottleneck which completely defeats the purpose of having a distributed system. This fundamental trade-off is exactly why companies like Twitter designed custom solutions like Snowflake IDs.
just use UUID v7, its not fully random, it includes a timestamp and random bits, so its also sortable by time...
2026-05-22 20:13:34
105
therussianplant :
So is the answer just random uuid
2026-07-17 01:18:01
2
jacob_gibbons44 :
Why not just prefix an autoincremented ID with the server ID…?
2026-05-23 17:36:49
42
chmbrln84 :
You haven't encountered UUID conflicts then? They are surprisingly common in large systems. Best bet is to use composite IDs made up of the primary key and a tenant ID or user ID. This way, auto increment works fine.
2026-07-19 07:00:45
0
* :
why the hell would y need to have unique ids across 3 server?
2026-05-23 19:13:57
11
itslennysfault :
Server prefix on the IDs... A-1, B-1, C-1,
(I always prefer uuids but just saying there are other options)
2026-05-24 05:38:01
6
Roel :
Let databases decide the auto increment. That fixes the issue. But yeah, UUIDis still better
2026-05-22 20:44:44
85
colley001_001 :
It’s a design issue, your primary key needs to be a compound key comprised of a server id and the auto increment id, AA1,AA2, BBB1,BBB2… C1,C2, CC1, CC2 as long as your server id is unique add as many as you need fill you boots .. design it right the problem is not the auto increment. Using GUIDs is incredibly inefficient, especially in db indexes that get fragmented and need frequent rebuilds , or determinate GUIDs that reset on server restart.
2026-05-24 10:10:30
20
Luis Gallardo :
Just go with UUID if need order UUID v7
2026-05-24 21:53:32
13
by_Gady :
why dont you just put. a prefix unique for each server? a1 b1 c1
2026-05-23 00:04:21
6
AlpacinoNogeek :
I worked with databases with millions of lines, never had a single problem with auto-incrementation. The sequence is usually stored in the database, and I cant see why you have that kind of problem. U can have a problem with the type of your ID, with millions or billions of data, u can reach the limit of a basic int, so you have to use a Long or a Big Int or anything rhat you can use
2026-07-15 23:01:35
0
Mikesch :
Couldnt you give a prefix to each one? A1, B1 C1?
2026-07-17 05:49:57
0
marz :
why not just reserve the first couple bits for the server id or have a serverID + ID be the primary key
2026-05-23 09:23:48
15
i dont need name :
wouldn't a somehow synchronous system still be needed? I mean it's almost a 0% chance but still what happens if we create 2 similar uuids? how does a know that b doesn't have the same uuid generated
2026-05-22 20:18:45
3
sam :
all of them u said they Will fail. then I may need that number so I don't expect a user to key in UUID. whys the solution?
2026-05-23 15:19:16
0
xms_ems :
you missed the old pattern, were a service fetches the "next number block" (1-1000) as atomic action, consumes the block and the fetches the next. This does not work for fiscal transactions/numbering but for the most part.
2026-06-11 15:17:06
5
pfropfen :
how is it safe to generate random uuids? i mean isnt there a (small) chance that there is generated 2 times the same id when you have enough entries?
2026-06-24 21:33:12
0
Santi :
Bro, just use the server to sufix the IDs
2026-05-23 01:29:39
7
︎KOFiblto :
do int64 random and hope for the best
2026-07-16 10:38:06
3
s :
what's the point to let each server to have control to decide the next increment? the sequence should be always be put in the db itself
2026-05-23 18:31:59
2
ChatGPT :
Create a main table with unique ID's and on every insert on any server get next id from this main table 😁
2026-05-23 09:01:24
1
phinixgerry42 :
you could use primes and powers of primes
2026-05-23 13:15:50
1
n.d. :
HiLo?
2026-05-22 23:27:57
1
أسَـامة الحِنّــاوي :
Can you explain discord’s snowflake if system next
2026-05-23 11:07:20
0
Rassim :
you can use ULID and get both the benifits of incremental and UUID
2026-07-13 23:22:23
1
To see more videos from user @greghogg5, please go to the Tikwm
homepage.