Ok, here's the catch: i am using ExtJS + PHP + MySQL to make a real-time chat site, based solely on AJAX requests. Yea, reverse AJAX would be cooler, but i haven't met anything easy to use enough to incorporate. (maybe you could suggest something !)
The site would be comprised of a buddy list, windows to talk to buddies, and a toolbar-menu-thing. Each user would have a buddy list. Each user would need to periodically update the 'online-ness' of their buddies through ajax, and each user would need to periodically check to see for new messages.
Hence, the DB has to be able to supply two things: new messages, and online-ness of the people in the buddy list. So, each user has to provide messages and online-ness to the database, in order to be distributed to the interested users.
The main issue in all this SQL and AJAX soup is how do you do that? Sending messages is easy: when FRED sends a message to WILMA, a new row in the table 'messages' is created, containing the name of the sender, receiver, message, and timestamp. WILMA's ajax checks for new messages, and queries the DB each 0.4 seconds or so for new messages.
But what about online status ? How does a user tell the server 'hey, i'm still here !'. And how do you distribute that to the rest of the users?
One idea is that everytime a user polls for new messages, he also queries the DB to update a table, in which his last poll's timestamp is stored. There would be another table with true/false values for each user, and another application would run in parallel with the server, updating the 'online' table, based on values in the 'lastajaxpoll' table, once every 5 seconds or so. But that would be a bit too resource intensive - imagine, every 0.4 seconds, doing a double run to the database, once to poll for new messages, twice to update your last-poll timestamp. Plus every 1 or so second to update online status. Plus messages.
At 10.000 users or so, would SQL still hold together to the huge number of queries? Yikes !
Anyone got a better idea?
I must say that my experience in web programming/databases is next to null, so advices are very welcome !
Thank you !