Server Load & Performance question

edited November 22 in Photon Server
Hello, I'm developing a fast-paced arena FPS with Unity & Photon Server. I was just curious about our performance:
Since it's a fast-paced game (Max 16 players - 8v8) with compact maps so some kind of action happens every second, which means that lots of operations must be sent.

For example: We have a specific operation for damage register event which is sent everytime a hit detection system returns a possible hit to another player. It first serializes a custom type to a byte array and then passes it over for the server to handle.

The custom type looks like this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using ExitGames.Client.Photon;
using System.IO;

[System.Serializable]
public class ServerWeaponDamageEvent {

	public int ActorID;
	public byte ActorCurrentWeaponID;
	public byte Critical;
	public float TimeSent;
	public Vector3 Direction;

	/// <summary>
	/// Serializes this custom type into a byte array.
	/// </summary>
	/// <param name="data">The binary data.</param>
	/// <returns></returns>
	public static void Serialize(Stream stream, ServerWeaponDamageEvent instance)
	{
		int num = 0;
		using (MemoryStream memoryStream = new MemoryStream())
		{
			IntProxy.Serialize(memoryStream, instance.ActorID);
			ByteProxy.Serialize(memoryStream, instance.ActorCurrentWeaponID);
			ByteProxy.Serialize(memoryStream, instance.Critical);
			SingleProxy.Serialize(memoryStream, instance.TimeSent);
			Vector3Proxy.Serialize(memoryStream, instance.Direction);
			IntProxy.Serialize(stream, ~num);
			memoryStream.WriteTo(stream);
		}
	}

	/// <summary>
	/// Deserializes this custom type from a byte array.
	/// </summary>
	/// <param name="customType">The custom type object.</param>
	/// <returns></returns>
	public static ServerWeaponDamageEvent Deserialize(Stream bytes)
	{
		int num = IntProxy.Deserialize(bytes);
		ServerWeaponDamageEvent damageEvent = new ServerWeaponDamageEvent();
		damageEvent.ActorID = ByteProxy.Deserialize(bytes);
		damageEvent.ActorCurrentWeaponID = ByteProxy.Deserialize(bytes);
		damageEvent.Critical = ByteProxy.Deserialize(bytes);
		damageEvent.TimeSent = SingleProxy.Deserialize(bytes);
		damageEvent.Direction = Vector3Proxy.Deserialize(bytes);
		return damageEvent;
	}
}
After that has been sent and server has processed it; a DamageInfo class will be serialized as well and sent back to the client as an event.

The DamageInfo looks like this:

using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
[System.Serializable]
public class ServerDamageInfo
{
	public int DamageAmount;

	public PlayerHitboxType BodyPart;

	//This is not handled currently by the server.
	public float UpwardsForceMultiplier = 150f;

	public Vector3 Force;

	public bool IsExplosion;

	/// <summary>
	/// Serializes this custom type.
	/// </summary>
	/// <param name="data">The binary data.</param>
	/// <returns></returns>
	public static void Serialize(Stream stream, ServerDamageInfo instance)
	{
		int num = 0;
		using (MemoryStream memoryStream = new MemoryStream())
		{
			IntProxy.Serialize(memoryStream, instance.DamageAmount);
			ByteProxy.Serialize(memoryStream, (byte)instance.BodyPart);
			Vector3Proxy.Serialize(memoryStream, instance.Force);
			BooleanProxy.Serialize(memoryStream, instance.IsExplosion);
			IntProxy.Serialize(stream, ~num);
			memoryStream.WriteTo(stream);
		}
	}

	/// <summary>
	/// Deserializes this custom type.
	/// </summary>
	/// <param name="customType">The custom type object.</param>
	/// <returns></returns>
	public static ServerDamageInfo Deserialize(Stream bytes)
	{
		int num = IntProxy.Deserialize(bytes);
		ServerDamageInfo damageEvent = new ServerDamageInfo();
		damageEvent.DamageAmount = ByteProxy.Deserialize(bytes);
		damageEvent.BodyPart = (PlayerHitboxType)ByteProxy.Deserialize(bytes);
		damageEvent.Force = Vector3Proxy.Deserialize(bytes);
		damageEvent.IsExplosion = BooleanProxy.Deserialize(bytes);
		return damageEvent;
	}
}
I was just wondering since it's a fast-paced game and many players, for example could be registering hits to another player with rapid-fire machine guns. How much would these kinds of actions cost performance wise (mostly network-traffic)?

Here are some specifications of our server:

OS: Microsoft Windows Server 2016 Standard 64bit
CPU: Intel Xeon CPU E3-1246 v3 @ 3.50GHz, 4 cores
RAM: 32gb 1600Mhz
Network: 1gbps

Thanks in advance,
Samuel

Comments

  • Hi, @Samuelroos

    from description and hardware you have provided I would say it will work. But the question is how many rooms will work? To get a clue you have to perform load tests.

    I think you will need to optimize traffic anyway after this tests, but I do not know where and how.
    Just a few hints
    1. https://doc.photonengine.com/en-us/server/current/reference/serialization-in-photon
    2. keep packets size not more than 1100 bytes. Otherwise, it will be split. This is especially dangerous for unreliable communication because in the case of packets splitting they will be delivered reliably

    best,
    ilya
Sign In or Register to comment.