开发者

How to simplified the process or starting distributed mnesia

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 doin开发者_JS百科g 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


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!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜