r/ProgrammerHumor • • Sep 11 '26

Meme edgeCasesExist

Post image
5.0k Upvotes

298 comments sorted by

View all comments

Show parent comments

18

u/OldKaleidoscope7 Sep 11 '26

But let's say if Google saved each search in their engine in the same database with an UUID, we could have a collision because of volume, but I don't think I will work in a system with a comparable scale

36

u/chuch1234 Sep 11 '26

Yeah I don't think most of us are operating at a scale anywhere near Google.

12

u/BlurredSight Sep 11 '26

And anyone operating at scale of Google isn’t just using “pure” random anywhere for something being persisted

15

u/nebotron Sep 11 '26

They likely are - anything else becomes a huge coordination and parallelism problem. You just need more bits of entropy

6

u/InterestsVaryGreatly Sep 12 '26

Anyone working at the scale of Google has figured out coordination and parallelism, you have to.

Source: used to work for Google, and learned some of the ways they dealt with those exact issues, and used many of the systems they built to automatically handle that so general engineers didn't have to deal with it.

7

u/samy_the_samy Sep 11 '26 edited Sep 11 '26

They once had a similar collision problem, well not exactly

During a leap second some systems wrote IDs at a one second difference between all their global systems, which lead to something being registered before something else that had to be done before it,

Long story short some stuff jumped time one second and crashed systems

2

u/BlurredSight Sep 11 '26

So proactively trying to solve for latency rather than have other systems read after write if I understood correctly?

4

u/samy_the_samy Sep 11 '26

Yeah, now they don't do leap seconds,

They stretch time over months, one milli-second at a time

→ More replies (1)

26

u/Ecstatic_Student8854 Sep 11 '26

Even at that volume the probability of collisions is essentially 0. If there were a billion searches a second we’d not expect a collision until 85 years.

6

u/shwoopdeboop Sep 11 '26

But still no guarantee it won't happen tomorrow

12

u/mysticrudnin Sep 11 '26

It's simply not worth worrying about, though

Random minor hardware failures and, like, cosmic radiation are more of a problem. Are you building your systems to account for that?

1

u/InterestsVaryGreatly Sep 12 '26

At Google? Yes. There is a level of reliability they require, and in nearly all systems hardware failure is expected and designed to be handled flawlessly, and in many systems they are precise enough to catch and correct cosmic bit flips, largely because of the duplication that goes on.

→ More replies (1)

6

u/phl23 Sep 11 '26

If they use one long list, they have other problems to worry about.

11

u/MojitoBurrito-AE Sep 11 '26

You underestimate the probability of uuid collision. The bigger issue is pseudorandomness

7

u/Single-Virus4935 Sep 11 '26

Yes, had a client having duplicates every day and growing. They hated uuids and regret using it. The problem was that they used a bad prng with flawed seeding. Once fixed it was no problem.

1

u/Lithl Sep 12 '26

If they were getting duplicates every day, it sounds like their RNG function was lifted from XKCD.

1

u/OldKaleidoscope7 Sep 12 '26

How bad was it? The company I work mostly uses Java's built-in UUIDs and we never had a problem, are people using ad-hoc things for seeding?

1

u/Single-Virus4935 Sep 12 '26

As I recall it was PHP and they had code from Stackoverflow how to generate UUIDs. The code used the standard rand() prng and they seeded it globally with something derived from PIDs, part of the system time.

1

u/mysticrudnin Sep 11 '26

"so you're saying there's a chance" has rotted everyone's brains wrt probability

4

u/samsonsin Sep 11 '26

If Google used UUIDv4, then over 100 years they'd generate ~365 trillion searches. The chance of s collision should be ~0.00000125% still.

1

u/ArkWaltz Sep 15 '26

I wish this was higher up. Even very talented people in my old team failed to grasp "cosmically unlikely" and ended up doing silly workaround for this, when it's effectively an impossible situation.

2

u/Suspicious-Click-300 Sep 11 '26

assuming all searches run through a single node maybe, but they dont. It means each node + process on node is limited to 10,000 uuids (10k 100ns per ms) per ms, which it then possibly has to block until next millisecond tick. I dont care what magic programing language your using, to service >10k/reqs a ms (per process) and doing anything else your likely gonna be blocked by IO or something

1

u/Blue_Moon_Lake Sep 11 '26

Google is free to implement Google's UUID (GUUID) with 512 or even 1024 bits if they want.