如何简化流程或启动分布式记忆
目前我正在开发一个游戏服务器,我的架构是每个游戏服务器在第一次启动时都会实例化一个mnesia db。 假设我想创建第二个节点,我的计划只是将相同的游戏服务器部署到第二个节点。
我的问题是:我希望我的游戏服务器的第二次部署将自动检测第一个节点上的 mnesia 实例,复制其数据库模式并成为第一个节点的集群。
我在 http://code.google.com/p/schemafinder/ 检查了 schemafinder 项目我想实现它是如何做到的,但看起来很复杂。
如果有人愿意给我一些启发,我将更加感激。
提前致谢
Currently I'm developing a game server, my architecture is that each game server will instance an mnesia db when it's first started.
Let say I want to create a second node, my plan is simply to deploy the same game server to that second node.
My problem is: I want the second deployment of my game server will automatically detect the instance of mnesia at the first node, copy its db schema and become a cluster to the first one.
I checked on schemafinder project at http://code.google.com/p/schemafinder/ and I want to implement how its doing it, but it seems quite complicated.
If any body out there willing to give me some enlightenment, I would be more grateful.
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您希望在计算机集群中使用相同的游戏服务器。您采取的第一步是好的:通过在远程计算机上复制来使其数据库可用。然而,分层设计整个游戏服务器非常重要。让游戏服务器本身成为它自己的应用程序、它自己的包。然后也单独设计其数据库。该数据库可以分段,在多台机器上复制。
通过这种方式,您可以为您的游戏服务器创建一个数据访问层,其中它将使用数据访问层 API 来访问您的数据库,无论是在远程机器上还是在本地在运行时不中断服务。让每个游戏服务器实例都有自己的 Mnesia 架构并不好,除非您确定驻留在这些数据库中的数据不会相关:
{local_content,true}
。在多台机器上复制相同的 Mnesia 架构(位于数据存储层中)会更安全。然后你的桌子就设计好了。公开模块中用于操作游戏数据的 API。从这里开始构建数据访问层(
注意:我谈论的是 3 层逻辑架构,物理架构可以采用任何形式,只要它能够解决硬件和网络故障即可。
)。在数据访问层,构建了容错的数据库节点访问。您放在这里的方法将从处理连接问题、对数据库节点等进行远程过程调用等抽象应用程序(业务逻辑)层。此外,这些方法应该能够检测“节点无法访问”错误,并且可以在运行时重试调用另一个数据库副本节点,游戏服务器没有注意到这种干扰。数据访问层可以通过在数据库节点之间有效地复用应用程序到数据库的调用来实现数据库节点上的负载平衡(也取决于可用性和故障转移机制)。
讲到这里就够了......
无论如何,我总结的一点是,将 Mnesia 与游戏服务器分开非常重要。通过这样做,您可以单独管理服务器应用程序,然后还可以单独担心数据访问。将数据库物理和逻辑布局与项目的其他部分分开将提高灵活性和可用性。将来您可以更改数据库设计和内容,而无需更改数据访问层。您甚至可以切换到另一个 DBMS,例如 Riak 或 Membase 服务器 在将来的某个时间,无需更改您的游戏逻辑。
另一件事:避免到处复制模式。从一开始就设计复制/分布式数据库架构。不要让游戏服务器将 mnesia 模式从一个节点复制到另一个节点以成为一个集群。让游戏服务器关心游戏逻辑和其他内容,让数据访问层关心游戏数据。
有一些启示,希望对您有所帮助。成功!
You would like to have the same game server available across a cluster of machines. The first step you took is okay: to have its database available by replication on remote machines. Its however important that you design you entire game server in layers. Let the game server it self be its own application, its own package. Then design its database separate as well. This database can be fragmented, replicated across several machines.
In this way, you can then make a Data Access layer for your game server in which it would use Data Access Layer APIs to reach Your Database wether on a remote Machine or Locally at runtime without disruption in service. Its not good to have each game server instance its own Mnesia Schema unless you are sure that the data that will reside in these database will not be related:
{local_content,true}
.Its safer to have the same Mnesia Schema (this is in your Data Storage Layer) replicated on several Machines. Then you have the tables designed well. Expose the APIs in the Modules that manipulate your Game Data. From here, start building the Data Access Layer (
NOTE: Am talking of the 3-tier Logical Architecture, the Physical Architecture can take any form as long as it caters for Hardware and Network Failures.
). In the Data Access layer, fault tolerant database node access is built. The methods you put here will abstract the Application (Business Logic) Layer from handling connection problems, making remote procedure calls to Database Nodes e.t.c. Also, these methods should be capable of detecting "Node Unreachable" errors and can at run time retry the call to another Database Replica Node without the game servers noticing this interference.The Data Access layer can do load balancing on the Database Nodes by efficiently multiplexing application-to-Database Calls amongst the Database Nodes (Depends on the availability and Fail over mechanism put in place as well).
Enough with this talk....
Any way, a summary of what i have put down is that its important that you separate Mnesia from your Game Servers. By doing this, you can manage the Server application alone and later also worry about the Data access separate. Separating your Database Physical and Logical Layout from other parts of your project will increase flexibility as well as availability. In future you can then change you Database design and stuff without changing the Data Access Layer. You can even switch in another DBMS like Riak or Membase Server at a future time without changing you Game Logic.
Another thing: Avoid copying schemas here and there. Design you replicated/distributed Database architecture from the start. Do not make you Game servers copy mnesia schemas from node to node in order to become a cluster. Let the Game server worry about the Game Logic and stuff and let the Data Access layer worry about the Game Data.
Some enlightenment there, i hope it helps. Success!