Page 1 of 1

Multiple Object creation per AJAX request -- bad idea?

Posted: Thu May 17, 2007 10:16 am
by fish123456
I am trying to leverage my knowledge of OOP to PHP, but I'm new to PHP, so I'm not sure if the following idea is realistic:

If I have a page that updates itself constantly (via AJAX) with data from other users who are on the same page, does it make sense to build a bunch of objects from a Database in order to work on those objects?

For example, let's say I am trying to allow users to play a game, so each action has to be propagated to all other users. This is done via AJAX polling. So every 3 seconds, the page polls for data. (i.e. index.php?user=fish&gameId=456) I was thinking about taking the user and gameIds, creating a Player object, populating the Player object with data from a database, and then performing some routines, such as Player->movePiece(). Thus, every single time a request comes in, one or more objects are instantiated, some functionality is performed, and when the request completes, the objects are destroyed.

Can anyone with experience speak to whether this is a bad idea in respect to performance when scaling to multiple dozens of games and several dozen users simultaneously?

Posted: Thu May 17, 2007 11:28 am
by Begby
I already answered your other almost identical post, please refer to that one.

Posted: Thu May 17, 2007 3:30 pm
by feyd
Duplicate thread. Locked.