I'm working on software for social network and I plan it to scale a lot. Actually, I'm updating timestamp
column every time user clicks, to be sure they're marked as online. When they do not click for 30 seconds, they're marked as offline. So simply, my queries are
UPDATE Users SET timestamp = UNIX_TIMESTAMP WHERE uid = 1; -- UNIX_TIEMSTAMP is current unix timestamp given by PHP's time()
SELECT Name FROM Users WHERE timestamp > (UNIX_TIMESTAMP - 30); -- (UNIX_TIMESTAMP - 30) is given directly by PHP (time() - 30)
In this answer, answerer said that
Will you be updating this table continuously? I doubt that would scale
is there a better way to update user's online status that would scale? Or do you think this is fine?
Users
?SELECT COUNT(*)
UPDATE Users SET timestamp = time() WHERE uid IN (ids, here)
) ? I currently do not expect activity on my own network, maybe after a few years, but I'd might want to sell it & I want to be sure it will be able to scale. If you have any tips, share them, pleaseCOUNT(*)
? What you want to handle is high concurrent activity against theUsers
table, and for that you need InnoDB.