提高MMO游戏性能 [英] Improve MMO game performance

查看:250
本文介绍了提高MMO游戏性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们都知道的MMO游戏的流行趋势。在这里玩家面对对方的现场。


  

我关注的领域,是球员的动作和比赛结果的存储。


  
  

通过NPGSQL适配器使用Csharp的和PostgreSQL 9.0


  
  

游戏客户端是基于浏览器的ASP.NET,并呼吁Csharp的功能对所有数据库相关的处理。


要了解我的查询,请考虑以下情形

我们存储在一个Postgres的表的游戏进度。

例如:比赛用四名球员开始,下面的活动


  1. 每个球员100hitpoints启动

  2. 播放机1罢工(我们指的图表,以打击转化为随机范围%生命值)

  3. 玩家2有92HP,并返回一个轻轻的打击,所以PLAYER1有98hp

以上两个回合,现在将在游戏进度表,因为

  ROW Player1HP Player2HP Strikefrom StrikeTo ReturnStrikeHP回合时间戳StrikeMethod
1 100 100 0 0 0 0
2 98 92 P1 P2 2 1

要找到,如果比赛已经结束,我们检查3名球员有生命值为零或者gametime经过从去年进步的规定超时值

我们的表有作为的PrimaryKey对tournamentid的playerids基础上随机32个字符的code(8为每个玩家)

有其他列,如铠甲,魔法,咒语,这都得到发扬光大每个球员,总共有48列 - 12每个球员和他们的属性。

最后有一个具有比赛的结果,tournamentid,tournament_timestamp,gameresult一个gameResult表(完整,PlayerSurrender,InvalidSession,SecurityHack,超时),winnerPlayer,playerMetrics,rowIDfrom,rowIDto

QUERY


  

我的问题是集中在博弈数据库或SQL减负
  查询


a)如何检测如果一个球员没有在simutaneously记录并开了两个游戏会话,但无需参考数据库或使用SQL

二)如何控制的记录激增到GameProgress表。让玩家获得更快的响应。服务器开始在高峰时间滞后或在1000玩家在线

 有SQL查询的巨大流量,为前。即使是在目前的游戏版本
每页显示12分钟或500的玩家有平均/最低100赛事在线/小时
在游戏进度表中,我们存储每个球员的举动
    4播放器的12轮tourament可以有48条记录
    加上法术或特殊物品,围绕相同数量
    共每小时96 tourament或48000的记录插入(500播放器/小时)

我正在使用C#一个后台进程,保持从GameProgresstable移动过期赛事记录到另一个数据库,我们有免费的游戏负载的服务器也在考虑。

C)应该多久我们运行真空完全的Postgres。

我打开新的应用开源或toPay,可以提高性能。外汇。我们使用FastCsvReader HTTP://www.$c$cproject。 COM /用品/ 9258 / A-快速的CSV阅读器提高服务器日志文件枚举。

问候
阿文德


解决方案

 如何检测如果一个球员没有在simutaneously记录并开了两个游戏会话
 但不必指一个数据库或使用SQL

假设你使用多台服务器创建一个流程的地方,只有注册登录和注销。你叫每当两个中的一个发生。您可以使用过程来检查用户是否已经登录,您可以通过LOADBALANCE这个过程中,例如,所有的服务器上运行,并使用一种算法只为用户的一个子集serverx使用。假设你有10台服务器,做(用户ID%10),以获得用户注册与登录/注销服务器的ID。

这样,你只能与服务器之间的调用内存做这些检查。也许你需要超时/ refreshcall使断开崩溃不会影响用户的用户或服务器登录,直到永远。

 如何控制的记录激增到GameProgress表。让玩家得到
响应速度更快。服务器开始在高峰时间滞后或在1000球员
线上

#1切换postgress数据库的使用SSD的存储

#2提升这整个过程到内存中,并没有使用数据库进行实时工作

在数据库中,而不是创建新的

#3更新记录

#4使用多个数据库和对他们分发用户

#5 ....

 我们的表有作为的PrimaryKey对tournamentid的基础上随机32个字符的code
playerids。

一个随机生成的主键是非常不好的做法恕我直言。使用的序列,或任何保证是唯一的。如果你随机code是不是随机的不够,你会得到非常讨厌的错误。你需要生成这个每场比赛只有一次,所以它不是一个性能瓶颈。

we are all aware of the popular trend of MMO games. where players face each other live.

My area of concern, is storage of player moves and game results.

Using Csharp and PostgreSql v9.0 via NPGSQL adapter

The game client is browser based ASP.NET and calls Csharp functions for all database related processing

To understand my query, please consider the following scenario

we store game progress in a postgres table.

For Example a tournament starts with four players and following activity

  1. Each player starts with 100hitpoints
  2. player 1 makes a strike (we refer to a chart to convert blows to hitpoints with random-range %)
  3. player 2 has 92HP, and returns a light blow, so player1 has 98hp

The above two round will now be in Game Progress Table, as

ROW Player1HP Player2HP Strikefrom StrikeTo ReturnStrikeHP Round TimeStamp StrikeMethod
1      100       100         0        0            0          0
2       98        92        P1        P2           2          1

To find if tournament has ended we check 3 players have zero hitpoints Or gametime has elapsed a stipulated timeout value from last progress

our table has a primarykey as tournamentid a random 32 character code on basis of playerids (8 for each player)

There are other columns such as armor , mana, spells , which all get carried forward for each player , in total there are 48 columns - 12 for each player and their attributes

Finally there is a gameResult table that has result of a tournament , with tournamentid, tournament_timestamp, gameresult (complete, PlayerSurrender, InvalidSession , SecurityHack, TimeOut), winnerPlayer , playerMetrics , rowIDfrom, rowIDto

QUERY

My questions are focussed on reducing load on Game database or Sql queries

a) How to detect if a player has not logged in simutaneously and opened two game sessions but without having to refer to a Database or using Sql

b) How to control the surge of records into the GameProgress table. so that players get response quicker. The Server starts to lag at peak hours or when 1000 players are online

There is a tremendous flow of sql queries, for ex. even in the current game version
There are average/minimum 100 tournaments online per 12 minutes or 500 players / hour
In Game Progress table, We are storing each player move 
    a 12 round tourament of 4 player there can be 48 records
    plus around same number for spells or special items
    a total of 96 per tourament or 48000 record inserts per hour (500 players/hour)

I am also considering using a background process in Csharp, that keeps moving expired tournament records from GameProgresstable to another Database where we have a server free of gameplay load.

c) How often should we run vaccum full of postgres .

I am open to new applications opensource or toPay, that can improve performance. For ex. we used FastCsvReader http://www.codeproject.com/Articles/9258/A-Fast-CSV-Reader to improve enumeration of server log files.

regards Arvind

解决方案

 How to detect if a player has not logged in simutaneously and opened two game sessions 
 but without having to refer to a Database or using Sql

Assuming you use multiple servers you create a processes somewhere that only registers logins and logouts. You have it called whenever one of the two happens. You can use that process to check whether a user is already logged in. You can loadbalance this process by, for instance, running it on all servers and use an algorithm to use serverx only for a subset of the users. Say you have 10 servers, do (userId % 10) to get the Id of the server a user registers login/logout with.

This way you do these checks only in memory with calls between servers. Possibly you will need a timeout/refreshcall so users that disconnect or servers that crash will not keep users logged in forever.

How to control the surge of records into the GameProgress table. so that players get
response quicker. The Server starts to lag at peak hours or when 1000 players are
online

#1 Switch the postgress database to using SSD's for storage

#2 Elevate this entire process into memory and do not use the database for realtime work

#3 Update records in the database instead of creating new ones

#4 Use multiple databases and distribute users over them

#5 ....

Our table has a primarykey as tournamentid a random 32 character code on basis of
playerids. 

A randomly generated primary key is very bad practice imho. Use a sequence, or anything is guaranteed to be unique. If your randomcode is not random enough you will get very nasty bugs. You need to generate this only once per game so it is not a performance bottleneck.

这篇关于提高MMO游戏性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆