This document is about: SERVER 5
SWITCH TO

This page is a work in progress and could be pending updates.

Photon Server Configuration

The main configuration file for Photon is the PhotonServer.config.
It is located in the binaries-folder of the SDK.
It is used to set up applications, listeners for IPs and performance specific values.
It does not contain config values for the game logic.

The default values make sure Photon scales nicely on more cores but do not overwhelm a regular machine.
In general, performance tweaks are not needed.

The settings listed here are most commonly used.
More options are described in the Photon Server Config Settings Page.

The Instance Node

Multiple instances are supported.
Each instance has its separate node in the config file.
An instance is a group of applications, listeners and other settings that should be used together when running the instance.

Example:

XML

<Configuration>
  <Instance Name="CustomPhotonServerInstance"
    MaxMessageSize="512000"
    MaxQueuedDataPerPeer="512000"
    PerPeerMaxReliableDataInTransit="51200"
    PerPeerTransmitRateLimitKBSec="256"
    PerPeerTransmitRatePeriodMilliseconds="200"
    MinimumTimeout="5000"
    MaximumTimeout="30000"
    DisplayName="OwnCloudTM">

    <!-- instance config here -->

  </Instance>
</Configuration>

The instance node can have these attributes:

  • Name: the name toe be used for the instance by Photon Socket Server.
  • MaxMessageSize: maximum size allowed of messages sent by a single peer in bytes.
  • MaxQueuedDataPerPeer: maximum buffer size capacity per peer in bytes.
  • PerPeerMaxReliableDataInTransit: The maximum amount of reliable data that a peer can send and which the peer has not as yet received an ACK for.
    In bytes.
    Once this amount of data has been sent, all future reliable data will be queued.
  • PerPeerTransmitRateLimitKBSec: The maximum amount of data (reliable AND unreliable) that can be sent in a second (in KB).
    This can be used to limit the amount of data that a peer can send.
    When the limit is reached further reliable data is queued and unreliable data is dropped.
  • PerPeerTransmitRatePeriodMilliseconds: How often we check the transmission rate limit.
    By default, we check every 250ms (i.e. 4 times per second) and we scale the PerPeerTransmitRateLimitKBSec by 4 for each check.
    A smaller value makes the data flow more consistent while a larger value makes the flow more jerky but uses less server resources.
  • MinimumTimeout (see "Timeout Settings")
  • MaximumTimeout (see "Timeout Settings")
  • DisplayName: the name to be displayed for the instance by PhotonControl.
  • DataSendingDelayMilliseconds (see "Delay Settings")
  • AckSendingDelayMilliseconds (see "Delay Settings")
  • ProduceDumps: Switch to enable or disable creation of "dump files" in case of a crash.
    Dump files are essential to find issues in the Photon Core.
  • DumpType (see "Photon Core Debugging")
  • MaxDumpsToProduce (see "Photon Core Debugging")
  • MaxDumpsToAttemptToProduce (see "Photon Core Debugging")
  • ...

Timeout Settings

Two values in the instance node describe how the server times out unresponsive UDP clients:
MinimumTimeout and MaximumTimeout.

A peer connected with UDP has MinimumTimeout milliseconds to respond before it can be disconnected.
The actual time until disconnect is determined dynamically per-peer based on the RTT history.
Previously good RTTs will disconnect faster.

TCP connections have a separate InactivityTimeout setting in the nodes TCPListener (also in the PhotonServer.config).
We set those to 5 seconds (5000ms).
If no request arrives during this time, the connection will be timed out and closed.
Clients will also regularly "ping" the server, to avoid this.

Keep in mind that a client independently monitors a connection and might time it out as well.
Both sides should have similar timeouts, fitting your game.

Delay Settings

The attributes DataSendingDelayMilliseconds and AckSendingDelayMilliseconds represent a trade-off between performance and minimal response times.
This delay directly adds some lag to reduce the traffic:

The wait allows the server to aggregate commands and sends them in one package.
The send delay is triggered when the server sends anything, the ack delay by incoming reliable data.

As you can see above, the default values are 50ms each.
We found this to be a good value but it causes a ~50ms round-trip time, even if the client and the server run on the same machine.

Depending on your game, you should load test with different values.
A delay of 0 is a special case that skips usage of timers, so avoid low delays < 10.

Log Settings

  • LogFileLocation: log file location for the unmanaged Photon Socket Server.
    It can be either an absolute path or relative to "PhotonSocketServer.exe".
  • LogFileName: the name of the unmanaged Photon Socket Server log file.
  • LoggingEnabled: enable or disable unmanaged logging for this instance.
  • LogUnimportantExceptions: whether or not to log some exceptions considered not important.

Schema Validation

  • ValidateSchema: enable or disable schema validation for this instance.
  • SchemaValidationFailureIsFatal: whether or not schema validation failure results in server shutdown.

The Applications Node

The config file defines which applications Photon should load on startup.
In the "Applications" node, several "Application" entries can be added.

To load multiple applications, simply add more application nodes (with unique names).
One of them can be made the default application by using its name ("NameServer" in the example).
The default app is the fall-back for clients that try to connect to an unknown application.

Applications that are not set up in the PhotonServer.config won't be loaded and don't need to be deployed.
When an application is in the config but the files are missing Photon won't start and name the issue in the logs.

Example:

XML

<!-- Defines which applications are loaded on start and which of them is used by default. Make sure the default application is defined. -->
<!-- Application-folders must be located in the same folder as the bin_Win64 folders. The BaseDirectory must include a "bin" folder. -->
<Applications Default="NameServer">
  <Application
    Name="Master"
    BaseDirectory="LoadBalancing\Master"
    Assembly="Photon.LoadBalancing"
    Type="Photon.LoadBalancing.MasterServer.MasterApplication">
  </Application>
  <Application
    Name="Game"
    BaseDirectory="LoadBalancing\GameServer"
    Assembly="Photon.LoadBalancing"
    Type="Photon.LoadBalancing.GameServer.GameApplication">
  </Application>
  <Application
    Name="NameServer"
    BaseDirectory="NameServer"
    Assembly="Photon.NameServer"
    Type="Photon.NameServer.PhotonApp">
  </Application>
</Applications>

Each application has a name clients could use when connecting to it.
The attributes supported by the application node:

  • BaseDirectory: defines the folder in which an application resides.
    It does not name the "bin" folder but expects it by convention.
  • Assembly: the ".dll" name of the application.
  • Type: the "main" class of the application (which derives from Photon.SocketServer.ApplicationBase).
  • ApplicationRootDirectory:
  • PassUnknownAppsToDefaultApp: If true when an unknown application name is supplied the default application is used. If false then this is a fatal error which will terminate a connection. Default is false.
  • StartTimeoutMilliseconds: Photon shuts down if the Application does not start in the configured amount of time.
    0 = no timeout is applied.
  • StopTimeoutMilliseconds: Photon shuts down if the Application does not stop in the configured amount of time.
    0 = no timeout is applied.

Listeners

These configure endpoints on your machine per protocol, IP and port.
Multiple listeners types can be defined.
Multiple listeners of the same type can be defined, opening several IP/port combinations.

Common Settings

These attributes are shared between most listeners.

  • Name: optional name of the listener.
  • IPAddress: The default IP 0.0.0.0 makes Photon listen on any locally available IP.
    Machines with multiple IPs should define the correct one here.
    By replacing the wild-card IP, Photon will open only the specific IP address.

Note: If you are using a license that's bound to an IP you need to set this IP in the configured listeners.

Back to top