educative.io

Why 17 bits for 1150 tweets per second?

Hi,

I have a basic question. I got the part where we need 31 bits for the epoch time. Can you please help me understand : "Since on average we are expecting 1150 new tweets per second, we can allocate 17 bits to store auto incremented sequence; "

Just curious since we can use 11 bits and get 2048 (ceil of 1150). Can you please help me understand if I am missing something here. Thanks a lot!

Thanks
V

Hi @Vijeya, you are right we don’t need more than 11 bits. The only problem would be to allocate 42 (31+11) bit number. To round it off, to a byte size, we have to allocate 48 bits (6 bytes). Or if the database only allows 4 or 8 byte numbers, we’ve to adjust based on that.

Hope this answers your question.

1 Like

@Design_Gurus yes makes sense! Thanks a lot for your quick response!