6.ProudNet Tips for performance enhancement

6.1How to conserve the communication traffic

It is highly suggested for developer to find out ways to conserve the communication traffic between hosts as much as possible.

Data Quantization helps in reducing the size of one message.

Dead Reckoning helps in reducing the number of exchanged messages.

If there are any unnecessary messages then it is better not to exchange them at all. For instance, let's say there is a quest that gamer can see. Rather than showing the entire string of quest, it is much more efficient to show the resource already saved in the game client.

6.2Optimizing multicast

The operation of Sending one same message to several hosts at one time is called multicast. We recommend optimizing multicast as followed as using ProudNet.

The basics of multicast optimization

When multicasting with RMI, it is much efficient to send a message to several hosts simultaneously by single call of RMI. How to send a message simultaneously is guided in 22. Sending a message.

Saving costs from MMO server multicast MMO

One of huge fees that developer has to pay as maintaining MMO game server is the speed of line where the server is running (i.e. IDC).

ProudNet has functions as followed which could save your cost in this field.

The effects of using below functions are introduced in the Nettention company website ( http://www.nettention.com).

Multicast of NPC simulation result

Generally simulation of NPC (Non Player Character) is run from server. You can Multicast the result of NPC simulation to clients, which can be transmitted via P2P connection of each client. More details are in 13. Routed multicasting several clients from server.

Multicast of PC (Player character) simulation result

Unlike NPC, the simulation of Player Character is run from each client. The client sends the position of PC, moving speed and etc. to the server which Multicast those information to clients near PC.

However, the processing of P2P creation, deletion, addition of member, and removal of member in ProudNet are remarkably fast. Taking a leverage on this, you can multicast position of PC without going through server and directly transmit it to other clients within the sight range of PC by P2P communication.

그림 6-1Multicast of PC status using P2P communication

Here are the key methods.

6.3Operating System (OS) of Game Server

동시접속자수가 100 이하인 경우에는 게임 서버의 운영체제로 무엇을 사용하던지 상관없습니다. 하지만 동시접속자수가 그 이상을 넘어가는 경우 게임 서버의 운영체제는 서버 전용 운영체제를 쓰는 것이 성능상 큰 이익을 봅니다.

ProudNet이 지원하는 서버 전용 운영체제는 Windows 2003 Server 혹은 이후 버전입니다. Linux도 지원하며, CentOS 6, Ubuntu 12 이상에서 테스트되었습니다.

6.4Method of using Server UDP Port

When client is connected to server then 1 TCP port will be appointed, which is nothing extraordinary since all TCP application programs are in this way.

However, ProudNet uses 1 UDP port for connecting with client. (If client can't use UDP port at default, then it uses TCP port instead.)

At that moment, Proud.CNetServer classifies the appointment policy of UDP port for each client connection.

The first is called per-client assign mode and the latter is called static assign mode.

At per-client assign mode, every client connecting to server will be appointed with each different UDP port. In this case, UDP port value will be used from one of UDP port numbers that server uses. If all of UDP port numbers are in use and more clients connect to server then random port numbers will be issued for them.

In static assign mode, there will be no case where another UDP port will be used than the list of UDP port numbers that server uses. And client connecting to that server will be appointed with one of UDP port numbers that server will use. This means, more than 2 clients will share the same UDP port in the manner of not affecting the flow of messages that could come from several clients on the same UDP port.

In general, per-client assign mode is better than static assign mode in performance-wise

Unless it is inevitable, we recommend you to use per-client assign mode which doesn't have disadvantages listed above.

But there are some catches in using per-client assign mode. If the number of client trying to connect to server exceeds the number of UDP port that server will use, then they will be appointed with random ports, which coincidently match with numbers not permitted by firewall of that server. When this happens, the UDP communication may not perform appropriately.

Some server firewalls have a feature that allows the use of port as long as data is outbound packet. By using this, you can secure the performance of communication safely as using per-client assign mode although there are unpermitted UDP ports for use. For more details, please refer to 3.1 Firewall setup to defend DDOS attack.

To decide which server will use which assign mode, you need to set Proud.CStartServerParameter.m_udpAssignMode when Proud.CNetServer.Start is called. And you can set the list of UDP ports that server will use from Proud.CStartServerParameter.m_udpPorts.

Summarizing everything mentioned above, the recommended ways to set assign mode, the length of UDP port list and firewall as using ProudNet are as followed.

Suggested level

assign mode

The length of UDP port list

Firewall setup

Most suggested

per-client

0

Permit when outbound packet is detected

Suggested

per client

CCU(i.e.: 40000)

Always permits numbers registered in UDP port list

Suggested

static

1/10 of CCU(i.e.: 4000)

Always permits numbers registered in UDP port list and blocks ICMP host unreachable.

Danger! Do not use this!

per-client

Insufficient to the maximum CCU(i.e.: 4000)

Always permits numbers registered in UDP port list

Danger! Do not use this!

static

Irrelevant

Irrelevant to the range of permitted UDP port and doesn't block ICMP host unreachable.

6.5Setting the number of threads in thread pool of server

At the startup of server(Proud.CNetServer.Start), you can assign the number of threads of Thread pool.

The role and function of server varies upon how many server processes are running and how many threads are created in the server computer.

Here are the typical guides.

6.6Speed-hack detection and performance of the server

17. Speed-hack Detection causes a specific amount of traffic between client and server, and traffic increases in proportion to the number of clients connected to the server.

In case of just client connection to the server PC with 4 GB of Xeon E312XX (Sandy Bridge) memory.

If not using 17. Speed-hack Detection, 0~3% of CPU usage is measured.

If using 17. Speed-hack Detection, 25~35% of CPU usage is measured.

Therefore, it is recommended to deactivate Speed-hack detection unless it is absolutely necessary. (Use of Proud.CNetServer.EnableSpeedHackDetector)

6.7Understanding burst time

Burst time can be categorized as CPU burst time and device burst time.

When developing a game server, there is a few things that you need to be careful is device burst time is long.

6.8Optimizing transmission operation routine

One of factors that negatively affects the server performance is routines take long to operate transmission.

In the case like this, it is important to search for transmission operation routines with lack of performance through 16.2 Approaching the moment of reception (Stub) call and solve them.

Then you need to determine the slow routines are in either device burst time or CPU burst time.

6.9Performance difference between Direct P2P and relay communication

As explained in 6. Overview of peer-to-peer communication between clients, peer-to-peer communication between hosts is based in 2 different methods, Direct P2P or relay communication.

Generally speaking, the latency of P2P communication two times larger than that of relay communication. Especially when the server is physically far away (for instance, if the server is located further than 3,000 kilometers), the gab will grow larger and larger.

Therefore, it is suggested to consider as followed.

But there is an advantage in using relay communication too. When there are many of P2P group members, it will cause excessive amount of uploads if client passes RMI to that P2P group. For solution to this, refer to Proud.RmiContext.m_maxDirectP2PMulticastCount or 11.2 Transmitting the latest message only.

6.10How to choose the right protocol for your project

As guided in 3. Protocol type of ProudNet, ProudNet supports reliable, Reliable messaging. From here and on, you can find useful tips for which messaging you should use.

First, you should send all messages by reliable messaging at the initial phase of your game developmen. (Use Proud.RmiContext.ReliableSend)

Then you should collect the contents of RMI message transmission as referring to 16. Approaching the moment of every RMI call .

In a normal game programming, the less than 20% of all defined RMI message types takes up 80% or more of the entire amount of RMI message transmission when you analyze the collected contents. Among these, there should be RMIs care less about data loss of 20% or below. A RMI transmitting the position of character 5 times per second would be a good example for this. ,

Through this process, you can edit your program as searching for RMIs with high transmission rate but can live with the loss then have them all use Reliable messaging.

6.11Detecting transmission overflows

Detecting transmission overflow from each hosts

ProudNet internally has Send Queue. When the amount of data exceeds more than what the network line and speed can handle, Send Queue puts the data on standby on memory until the transmission is complete.

If the communication traffic is excessive, you can mitigate it by using 11. Traffic auto-control function (Throttling). Also, you can prevent the overflow by measuring the amount of traffic since the number of Send Queue will increase equivalent to the amount of traffic.

Here are the methods of measuring Send Queue.

Proud.CNetServer.GetClientInfo

Proud.CNetClient.GetPeerInfo

And use Proud.CNetPeerInfo.m_sendQueuedAmountInBytes.

Detecting transmission overflows for each RMI type

Event callback Proud.IRmiProxy.NotifySendByProxy that is occurring when you call RMI has parameter Proud.MessageSummary You can measure traffic from RMI with it.