educative.io

Is 4 Byte good enough for userid?

The lesson mentions this while calculating storage requirements.
UserID (4 bytes)
Name (20 bytes)

Is this really enough?

Anastasia Charolette Fernandes will be 30 Bytes
and 01012010 is 8 bytes

ref: https://www.javainuse.com/bytesize

Hi shrikant,
The 4 bytes that are mentioned in the lesson are just for UserID which they have assumed to be integer and an integer is of 4 bytes. Regarding Name (20 bytes), again these are just assumptions to estimate the data size required for all tables. You can increase the bytes required for both UserID and Name and then perform the data size estimation according to them.

They said they will have 500M total users. Max unsigned integer of 4 bytes is about ~4M.
It seems there is a clear mistake here. We should use 8 bytes for UserID

4 byte unsigned is 2^32 -1, which comes to be around 4 billion, not million.


Course: Grokking the System Design Interview - Learn Interactively
Lesson: Designing Instagram - Grokking the System Design Interview