Note that there are some explanatory texts on larger screens.

plurals
  1. POAzure: advice on making a simple multiplayer card game scalable
    text
    copied!<p>I have a multiplayer card game (up to 4 players can play the same instance of the game) up on facebook. The game is small and is hosted on a single server. I am now looking into scalability as I am hoping that soon one server won't be enough.</p> <p>The server stores in Memory a list of all games which are underway: <code>List&lt;Game&gt;</code></p> <p>When a client makes a request (for example throws a card) it POSTs a message to the server. Now here comes the tricky part. The server does not send the response immediately but rather keeps checking if any other player has modified the game state before it replies. This approach works very well because the client (silverlight) is not constantly polling the server.</p> <p>What approach would you recommend I take in Azure? My main priority is getting a fast response to the clients and avoiding the constant polling from the client.</p> <p>With my limited Azure knowledge I am thinking of taking this road:</p> <p>Store the games in azure table storage instead of in memory.</p> <p>This will be done in the webrole: <strong>PSEUDOCODE:</strong></p> <pre><code>void Page_LoadOfAnAspxPage { // deserialze the message from the posted information Message msgClient = ...; // retrieve game from table storage Game g = RetrieveFromTableStorage(gameGuid); // post message to game g.ProcessClientMessage(msgClient); // save back to table storage so other game clients can be aware of new state SaveToTableStorage(gameGuid, g); // now wait until another client modifies the game while(true) // will I be incurring hosting charges (transactions for what is going on in this while loop)??? { // grab game from table storage g = RetrieveFromTableStorage(gameGuid); // has something changed? MsgResponse response = g.ProcessClientMessage(msgClient); if (response.ActionName != ActionName.GameHasNotChanged) { // some other client changed the game. // give this response back to our client break; } // sleep a little and check again... Sleep(xx); } } </code></pre> <p>Do you believe this approach will work? Any roadblocks I might run into? I would be really grateful for any suggestions/improvements.</p> <p>Thank you!</p> <p>santiago</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload