I’m developing a game which will feature a ‘light’ instant messaging system; ‘light’ in the sense that I want all logged-in players to receive a “new message!” notification if another player sends him/her a message. It doesn’t have to be ‘instant’ like with a chat service, so I’m thinking about having the game check for ‘new messages’ every 20 seconds.
Now, I’d prefer to use what I already know, which is using AS3 to call PHP pages, querying a database and receive a response in the form of XML which can be used in AS3.
So, my question is this: How feasible / stupid would it be to such a ‘light’ IM feature using this method: I call “checkForWaitingMessages.php” from my Flash game every 20th second, passing along the player’s login id. The PHP page checks if there are any ‘waiting messages’ in my database under that player id, then returns all ‘waiting messages’ in XML form, which I use Actionscript to display to the player. This happens every 20 seconds.
My main concerns are:
- How much of a strain does it put on a normal hosting service that I request an XML document every 20th second?
- What if there are 100 players logged in, making it 100 requests every 20th second? What about a 1000? Is this all in the realm of trivialities, or will this become to cumbersome to realistically implement?
- Are there any ways to optimize this process in terms of lightening the data load or easing the strain on the server? Remember that I’d prefer to keep it to the mentioned technologies.
I’m not looking for any definite answers here, as I know there probably aren’t any unless I provide the exact size of the XML documents and the number of players, but I’ve never done anything like this before, and would like to know if it’s completely out of this world. I simply don’t know what the norms are in terms of data transfer and frequency in this context.