educative.io

How was the object size of 500 bytes calculated?

Let’s assume that each stored object will be approximately 500 bytes (just a ballpark estimate–we will dig into it later)

Can someone point me to where the 500 value came from? May be it was in the solution as it says but could not find it.

Hi @Harry,

Thanks for posting the question.

500 is just an estimation to build an understanding of the data objects we will be dealing with. The actual size is revealed in the 5th section “Database Design”. Over there, you can see the URL object will take 540 bytes (16(hash) + 512(OriginalURL) + 4(CreationDate) + 4(ExpirationDate) +4(UserID)).

A lot of times, it is good to estimate the scale of data we will be dealing with. This helps in designing the service.

2 Likes

Why do we use only 1 Byte per character? For example, the original URL is 512 characters but do we expect URLs to contain non-ASCII characters? Maybe we should provide size for UTF-8 encoding?