MMO Server - Optimising Database Access for User State Data
I am writing an MMO Server using the following technologies and languages: .Net Framework 4, C#, SQL Server 2008 R2, Entity Data Model, LINQ.
The question I have is regarding how and when to access permanent storage开发者_如何学Go (SQL Server) for user state data to increase server performance.
It used to be that when a user logged on to an MMO server, you would load all of the user data into RAM for fast read/write access during the lifetime of the user connection. When the user logs off from the server, that data would be persisted to the Database.
With the advent of the Entity Data Model, and it's associated caching, is this method required anymore? When should Context.SaveChanges(); be called if this is the case?
Any guidance would be appreciated regarding my question. Thanks.
MORE INFO: I dont think anyone is addressing the Caching ability of the .NET Entity Model. As far as I understand the .NET Entity Database model does the caching for you, and thus queries are not always ran against the actual database, but instead against data in RAM. So from my point of view I do not have to differenciate between RAM data access and Database access. Is this a correct assumption?
I'm no expert but I would say stick with your original design. You may end up taking up more memory trying to keep a context open and have it track all the changes through the lifetime of a user's connection. I would suggest using POCO, load the objects on user logging in, close the context, then when the user logs off, open a new context, attach your objects back then save changes.
Well, if you need performance, you might want to use a pool of servers with memcached.
Once a user connects, you load all infos you have about him in the cache, have a daemon periodically flush it to the database, and update the data in the memcache.
You will always have better performance for data in RAM than in DB.
精彩评论