This document is about: PUN 2
SWITCH TO

PUN Classic (v1), PUN 2 and Bolt are in maintenance mode. PUN 2 will support Unity 2019 to 2022, but no new features will be added. Of course all your PUN & Bolt projects will continue to work and run with the known performance in the future. For any upcoming or new projects: please switch to Photon Fusion or Quantum.

Regions

The Photon Cloud provides low latency gaming globally by hosting servers in various regions.

Clients get the list of regions from our Photon Name Servers. Over the lifetime of a project, new regions may be added or old ones may be deprecated and removed.

Each region is completely separate from the others and consists of a Master Server (for matchmaking) and Game Servers (hosting rooms).

Below is an outline of the client workflow:

(1) Clients retrieve a list of available regions from the Photon Name Servers.

(2) The client selects one of the available regions — either automatically based on the lowest ping or via manual player choice — and connects to the region's Master Server. The Master Server is responsible for matchmaking and creating or joining a room on a Game Server within that region.

(3) Finally, the client connects to the designated Game Server in order to join the room. This Game Server is located in the same region as the Master Server the client connected to in step (2).

Photon Cloud Regions' Connect Flows
Connect to Photon Cloud regions

With the Region Allowlist, you can define which regions should be available per AppId (see below).

Available Regions

The Photon Cloud consists of servers in several regions, distributed across multiple hosting centers worldwide.

Each Photon Cloud region is identified by a "region code", which is a case insensitive, short string.
For example, "EU" or "eu" are both accepted and refer to the same Europe region.

The lists below indicate the location of the hosting center and the region code for each region.

Photon Cloud for Gaming

The Photon Products Quantum, Fusion, Voice, Realtime and PUN are available to the Photon Cloud for Gaming in the following regions.

RegionHosted inCode
AsiaSingaporeasia
AustraliaSydneyau
Canada, EastMontrealcae
Chinese Mainland (See Instructions)Shanghaicn
EuropeAmsterdameu
Hong KongHong Konghk
IndiaChennaiin
JapanTokyojp
South AfricaJohannesburgza
South AmericaSao Paulosa
South KoreaSeoulkr
TurkeyIstanbultr
United Arab EmiratesDubaiuae
USA, EastWashington D.C.us
USA, WestSan Joséusw
USA, South CentralDallasussc

Photon Chat is available in the following regions:

RegionHosted inCode
AsiaSingaporeasia
EuropeAmsterdameu
USA, EastWashington D.C.us
Chinese Mainland (See Instructions)Shanghaicn

Photon Industries Premium Cloud

The Photon Products Quantum, Fusion, Voice, Realtime and PUN are available to the Photon Industries Premium Cloud in the following regions.

RegionHosted inCode
AsiaSingaporeasia
EuropeAmsterdameu
IndiaChennaiin
JapanTokyojp
South KoreaSeoulkr
USA, EastWashington D.C.us

Further regions for the Photon Industries Premium Cloud are planned: Australia (AU), South America (SA), US West (USW), South Africa (ZA).

Photon Chat is available in the following regions:

RegionHosted inCode
USA, EastWashington D.C.us

Regions for China for Gaming/Industries

There are special conditions for using the Photon Cloud Region Chinese Mainland:

  • Access must be unlocked (see below)
  • Photon Voice is not available in China
  • 20CCU for development is free (non commercial use)
  • Only a 500CCU subscription available on Photon Cloud
  • Large setups need custom agreements

The Photon Products Quantum, Fusion, Realtime, PUN and Chat are available to the Photon Cloud in the following regions:

RegionHosted inCode
China MainlandShanghaicn

Region Allowlist

The Region Allowlist enables you to customize the available regions per application directly from the dashboard. Clients using the Best Region feature, will adapt automatically.

By using using more or less regions, you balance the quality of service (roundtrip times are better, when there is a region close to players) versus the matchmaking experience (less regions mean more players per region).

To define the regions per app, open the dashboard, click "Manage" for a chosen application and then click "Edit Allowlist".
You will find an input field to enter the list of allowed regions as follows:

  • the available regions are listed above per SDK and sometimes separately for the Industries Circle.
  • the allowlist must be a string of region codes separated by semicolons. e.g. "eu;us".
  • region codes are case insensitive.
  • undefined or unrecognized region codes will be ignored from the list.
  • empty ("") or malformed string (e.g. ";;;") means all available regions are allowed.

Within 10 minutes of a change (confirm and save), the Name Servers will send the filtered list to connecting clients.
To avoid conflicts on the client side, connect to the "Best Region" by ping or make sure to pick a region received with the regions list.

Note: Changing the available regions for a popular app will affect the Peak CCUs in multiple regions, which is the basis for subscription fees. Adjust the subscription plan as needed to avoid the more expensive overage fees. Reducing the subscription is perfectly fine when the switch settled down.

How To Choose A Region

Users in the US have the lowest latency if connected to the Photon Cloud US region. Easy.


But what if you have users from all over the world?

Options are..

  • a) let the game client ping the different Photon Cloud regions and pre-select the one with the best ping, read our how to.
  • b) distribute client builds tied to a region, so users from different regions connect to different Photon Cloud regions or
  • c) let the user choose a matching region from within your game`s UI.
  • d) let all users connect to the same region if the higher latency is acceptable for your gameplay.

All Photon Cloud apps are working in all available regions without any extra charge.

See pricing.

Photon Cloud's dashboard lets you monitor the usage of your game in each region and easily upgrade or downgrade your subscription plan.

Go to your dashboard.

C# Realtime API

Photon Realtime (used by most Photon SDKs) can detect the Best Region to connect to and enables you to stick to that region.

To do so, clients always fetch the list of available regions from the Name Server on connect.
The servers response is used to setup the LoadBalancingClient.RegionHandler which is also provided via the callback OnRegionListReceived(RegionHandler regionHandler), as defined in the IConnectionCallbacks.

Typically, the next step is to call regionHandler.PingMinimumOfRegions() to detect the current ping to each region. You need to pass a method to call on completion and in best case you can also pass the "best region summary" from a previous run (explained below).

After pinging the servers, the (new) results are summarized in the regionHandler.SummaryToCache which should be saved on the device for later use.

Without the SummaryToCache from a previous session, all regions will be pinged, which takes a moment longer.
If a previous result is available, the client will check:

a. if the region list changed (covers the case if the "previous best region" is still available)
b. if the ping is no longer acceptable (>= 1.5x slower than previously saved reference value)

If either applies, all regions are pinged and a new result gets picked.

Using Best Region works well with the server-side Region Filter in the Dashboard.
It enables you to change the list of regions available to players on demand.

To access the list of regions or to override previous results, refer to the API Reference for regions.

PUN

"Best Region" selection is done by default when you use PhotonNetwork.ConnectUsingSettings().

Aside from automatically saving the results in the player preferences, the workflow is the same as in the Realtime API.

The best region is "sticky".
This means the client will typically use one region for a longer time.
On subsequent starts, it will ping this region again.
PUN automatically stores the best region summary using Unity's PlayerPrefs.

For convenience and debugging purposes, the current "Best Region" and its ping are exposed in the PhotonServerSettings in Unity Editor.
However, that is only valid for the Unity Editor's play mode.
Builds that run on the same machine as the Unity Editor may have a different Best Region.

Best Region Considerations

"Best Region" option is not deterministic.
Sometimes it may be "random" due to little variations or exact same ping calculations.

Theoretically, you could:

  • have the same exact ping to multiple regions from the same device. So it is random, if you end up with different regions on clients connected to the same network.
  • different ping values for the same region on different devices (or different retries on the same device) connected to the same network.

For instance, in the case of "us" and "usw" (or "ru" and "rue"), you could either make use of the online regions allowlist to select the ones you want and drop the others or connect to an explicit region.

To debug, set the logging level to "Info" and clear the "current best region" (in PUN: PhotonNetwork.BestRegionSummaryInPreferences = null). Have a look at the details or send us the log via mail.

Development Region

Starting from PUN v2.17, we added a new feature called "Dev Region".
It's a new setting available in PhotonServerSettings.
With this setting, all development builds will use the same region, avoiding initial matchmaking problems with the "Best Region" selection.
"Development build" is enabled automatically when the PhotonServerSettings gets created and the "Dev Region" is set during the first run (PlayMode) in Unity Editor.

The "Dev Region" is only used in Unity Editor and in "Development" builds, when you use PhotonNetwork.ConnectUsingSettings() to connect.
You can also disable the "Dev Region" in Unity Editor and "Development Build" by simply deleting the value.

So to avoid Best Region selection issues during the development phase, make sure to update to the latest PUN 2 version.
Run once in Unity Editor (enter PlayMode and connect).
You can do so from any of the demo scenes.
This first connection from Unity Editor will set the "Dev Region" which can be seen from the PhotonServerSettings inspector.
Once this is done, you can build and test from devices or do new build if you already did before.
You will notice that "Development Build" is enabled now from Build Settings and should remain this way during the development period.
This way, all clients (Unity Editor and builds) will connect to the same "Dev Region".

Before going into production, do not forget to disable development build.

Note: if a client is connected from a development build or from Unity Editor and the other is connected from a non-development build, they could be connected to two different regions.

Using The Chinese Mainland Region

You need to request access to the Chinese Mainland region for your Photon application. Send us an email so we could unlock it for your AppID.
On our Dashboard, you can not subscribe to paid plans to be used in the Chinese Mainland region. Reach out to us by email to receive a quote for any subscription: hello@photonengine.com.

The Photon Name Server has to be local to China, as the firewall might block the traffic otherwise.
The Chinese Photon Name Server is "ns.photonengine.cn".

Connecting with clients from outside of China mainland will most likely not produce good results.
Also, connecting from the Photon servers to servers outside of China mainland (e.g. for Custom Authentication, WebHooks, WebRPCs) might not be reliable.

Important: in the current phase, changes you make to your app via your dashboard are not automatically reflected in the app caches for China. Let us know by email if you have an update request there.

For legal reasons, you need a separate build for China and we recommend using a separate AppId with it.
For example, use a compile condition (of your choice) to change the AppId and the Photon Name Server depending on the build.

Follow the instructions corresponding to your client SDK to make a special build for the Chinese market.

PUN 2

Using PhotonServerSettings

PUN 2: PhotonServerSettings for China
PUN 2: PhotonServerSettings for China

Using Code

C#

void ConnectToChina()
{
    AppSettings chinaSettings = new AppSettings();
    chinaSettings.UseNameServer = true;
    chinaSettings.ServerAddress = "ns.photonengine.cn";
    chinaSettings.AppIdRealtime = "ChinaPUNAppId"; // TODO: replace with your own PUN AppId unlocked for China region
    chinaSettings.AppVersion = "ChinaAppVersion"; // optional
    PhotonNetwork.ConnectUsingSettings(chinaSettings);
}
Back to top