I developed a board game app (for android/iphone) and added a multiplayer component to it. Was thinking of using app engine (java) for the backend, so implemented that way, but turns out the cpu costs are probably going to be too high (app engine is probably not the best choice for this sort of app).
I don’t have much experience with php’s performance, am wondering if anyone can give me an idea if I’m heading down a bad path translating it to php. Basic steps would be:
- Http request is made to my server, player is trying to perform a move (it’s a turn-based game).
- Fetch game state from database. This will probably be stored as a flat json string (there’s not much point to creating a schema for the gamestate).
- Deserialize json string into workable gamestate objects (like houses, cars, etc).
- Perform gamestate manipulations finally (like moving the player’s car to a new house etc).
- Serialize modified gamestate, persist back to database.
- Send json response back to player, which will contain updated gamestate.
I don’t know if that’s a lot of work to try doing in the context of a single http operation. Some numbers:
- Expecting about 500 players using the service at any given time.
- Each game consists of only 2 to 8 players, each game is completely independent.
- The json gamestate object is about 25k in size when serialized.
- The json gamestate object will have to deserialize about 300 objects to restore the complete state of the game (houses, cars, etc).
Is this unrealistic? The best solution I think would be to get a dedicated server, and just leave all the gamestates in memory, but I’m trying to get by with some of the shared hosting platforms for now. This means I have to keep going back and forth to the database to get gamestate, deserializing and serializing.
Thanks for any thoughts
This sounds ok. You may want to consider using a NoSQL database such as MongoDB if you are just going to be storing json, but this may not be available on a shared host.