IPv4 Fremnet Logo
TOOLS, TINKERINGS & CODE

Help me help you

Twitpocalypse - The math! · Jun 14, 14:17 by Shannon Wynter

I’m sorry but I find it immensely amusing that someone could be lazy enough to just use a signed 32 bit integer in a twitter app.

Seriously, even an unsigned 32 bit integer isn’t a good idea.

At last check, the current ID is 2,161,653,083 and the rate of twits is 156 twits per second. So lets do some simple math here.

Lets not bother with the signed 32 bit integer, and skip streight ot the unsigned 32 bit integer.

((2^32) – 2161653083) / (156 * 60 * 60 * 24) =
(4294967296 – 2161653083) / (156 * 60 * 60 * 24) =
2133314213 / 13478400 = 158.28 (days)

So, in less then 159 days the unsigned 32 bit integer will roll over…

Now, lets do the same math with an unsigned 64 bit integer

((2^64) – 2161653083) / (156 * 60 * 60 * 24 * 365.242199) =
(18446744073709551616 – 2161653083) / (156 * 60 * 60 * 24 * 365.242199) =
18446744071547898533 / 4922880455.0016 = 3747144428.99 (years)

I don’t think anyone will care about twitter in as little as 2 years, so a 64 bit unsigned integer will probably do the job, but you never know – people might start posting at 300 or even 600 twits per second.

Do your bit to save twitter, only twit when you absolutely need to!

Comments

your_ip_is_blacklisted_by sbl.spamhaus.org

---== Copyright Shannon Wynter - All rights reserved - All wrongs avenged ==--- email