2010-02-09 32 views
0

我有一个多人纸牌游戏(最多4名玩家可以玩同一个游戏实例)在Facebook上。 游戏很小,托管在一台服务器上。 我正在研究可伸缩性,因为我希望很快就会有一台服务器不够。Azure:关于制作简单多人纸牌游戏可扩展的建议

在存储器服务器存储的哪个正在进行的所有游戏的列表:List<Game>

当客户端的请求(例如抛出一个卡)它发布消息到服务器。 现在来了棘手的部分。 服务器不会立即发送响应,而是保持检查其他玩家是否在回复前修改了游戏状态。 这种方法工作得很好,因为客户端(silverlight)不会不断地轮询服务器。

你会推荐我在Azure中采用什么方法?我的主要优先事项是快速响应客户,避免客户不断进行轮询。

用我有限的知识天青我想带这条道路:

存放在Azure Table中,而不是存储在内存中的游戏。

这将在webrole来完成: 伪代码:

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); 
} 
} 

你相信这种方法是否行得通呢?我可能遇到任何障碍吗? 我会很感激任何建议/改进。

谢谢!

santiago

回答