I need to implement a messaging system on a web application. It’s powered by PHP and MySQL and will allow registered users to message one another.
So here’s my worry: What will happen after i let the site run for two years and it gets thousands of users with dozens of friends who will each send each other millions of messages over the time?
How are the “big boys” of the IT industry handling those problems, for example Facebook? Surely their messages cannot all fit into one table (MySQL or otherwise)… But even transferring older messages in (one) archive table won’t work forever.
I will in no way build a website that will be even remotely comparable to Facebook, but i still want a solution that won’t bug out after a year or two.
Make a search for Max Value for SQL BIGINT. This script used to overflow when I wrote it a few years ago on a 32-bit machine. It’s much less of a problem now!
http://dev.mysql.com/doc/refman/5.0/en/numeric-type-overview.html
http://www.laprbass.com/RAY_integer_overflow.php
According to my rough calculations, if you’re aggregating messages at the rate of 1,000 per second and you’re using UNSIGNED BIGINT for your AUTO_INCREMENT key, you will experience an overflow in about 570,000,000 years. So it follows, more or less, that if you’re collecting the messages at the rate of 1,000,000,000 per second, you’ll have a problem in shorter order – perhaps around 570 years from now. But the good news is that if you’re collecting messages at the rate of even 100,000 per second, the VC community will be throwing money at you!