This document is about: PUN 1
SWITCH TO

PUN Classic (v1)、PUN 2 和 Bolt 處於維護模式。 PUN 2 將支援 Unity 2019 至 2022,但不會添加新功能。 當然,您所有的 PUN & Bolt 專案可以用已知性能繼續運行使用。 對於任何即將開始或新的專案:請切換到 Photon Fusion 或 Quantum。

Frequently Asked Questions

Which Photon product is the right one for me?

This is a difficult question to answer as it depends on the game you are making and the specifics of your project. However we can recommend the following:

Feel free to reach out to us if you still have questions.

What is the difference between Photon Realtime and PUN?

Photon Realtime wraps up all generic features needed for the load balancing of Photon. It is a product as much as a defined workflow to use Name Server, Master Server and Game Servers. Photon Realtime (a.k.a. LoadBalancing) is the basis for many games using Photon.

While Photon Realtime is independent from Unity, PUN adds many comfortable features for Unity and makes Realtime (the lower level) even easier to use.

Both products share the same backend, same server applications, same low-level stuff, same core concepts. At first PUN was meant to be a better UNet (old Unity Networking): preserve a similar API with a more solid backend and rich features. Then it slowly diverged and became the number 1 solution for multiplayer on Unity.

While we do have a Photon Realtime Unity SDK, PUN has more high level out-of-the-box features like:

  • Magic Unity callbacks
  • Extra Unity components that serialize and sync. networked objects for you: most important one PhotonView
  • PunRPC
  • Offline mode
  • ...

Read more here.

However, while PUN supports webhooks and persisting room states, it is still not 100% able to restitute networked objects' state in the scene(s) when loading a saved game. Read more here.

What is the difference between LoadBalancing API and Photon Realtime?

LoadBalancing API and Photon Realtime can be two different names for the same thing. The LoadBalancing API or the LoadBalancing Client API is the programming interface available in the client SDKs we provide for the Photon Realtime product.

Photon Cloud

Is Photon Cloud down?

You can check Photon Cloud status here or follow @photon_status on twitter to get notified about status updates.

What is the default Photon region?

Clients should be able to connect to Photon Cloud as long as at least one region is available. So to guarantee this, a default value is configured or is used when the developer does not explicitly set one or choose "Best Region" option. The default value could vary by client SDK. In native SDKs, it is the value at index 0 of the region list returned by server in OpGetRegions. On Unity and DotNet SDKs, the default region should be "EU".

Is it possible to disable some regions?

Yes. It works in the other way around by defining a list of allowed regions. Read more about the "Dashboard Regions Filtering".

Load Balancing

What is the maximum number of players supported by Photon rooms?

Most Photon multiplayer games have 2-16 players, but the theoretical limit of players/peers per room can be quite high. There are Photon games live with 32 or even 64 players and in virtual conferencing scenarios it can be in the hundreds. However, sending too many messages per second (msg/s per room) can cause performance issues depending on the client's processing power coping with data. While high player numbers in e.g. turnbased games are totally fine, more than 8 players in a fast-paced action game likely will require you to implement interest management. This way not every player receives every message from all the other players.

The number of players per room is the main factor for increasing data traffic inside the game room: This is why we recommend keeping your msg/s per room count below 500. Photon does not enforce this limit, but relies on a fair use policy. Keeping an eye on your bandwidth usage is always important and it helps to ensure you stay within your plans included traffic range of 3GB per CCU.

Is there a limit for Photon strings?

Photon uses strings for lots of purposes: room name, lobby name, UserID, Nickname, custom property key, etc.

Photon binary protocol can serialize strings up to 32767 one-byte-characters. For names and UserIDs 36 characters should be enough (e.g. a GUID is 36 characters). However, for custom properties keys, you should use shorter strings to minimize their overhead. This is especially important for properties that are visible in the lobby, as those are part of the room lists and get sent to everyone in the lobby, not just the couple of clients in a room.

Is there a limit for the number of custom properties?

No. However, note that the more Custom Properties are set, the longer the clients load time will be because when joining the room, the clients also receive all of the properties. If you have too many of them and clients' load time exceed a certain amount of time, this might result in a disconnect for them.

Can I send a huge message using Photon?

We do not recommend transferring large data (i.e. files) using Photon unless you know what you are doing. We advise you to optimize the data you exchange and get in touch with us if you really have to send a very big message.

Photon Cloud has a server side limit for client buffers which is 500KB. So depending on the context a message could be considered:

  • "too big" for our per client buffer size on Photon Cloud > 500KB. If a client hits this limit in a short period of time, it will be disconnected by the server.
  • "too big" to be sent with UDP without resulting in an amount of fragments that might cause problems > 100KB.
  • "too big" to be sent without splitting it up into multiple UDP packets > 1.2KB (including protocols overhead).

For messages that get sent very regularly (10 times a second or even more often) we would recommend to keep their size below 1KB.

If a message only get sent rarely (for example once at the start of a match), then a size of multiple KB is still fine, but we still would recommend to keep it below 10KB.

In exceptional cases something like 20KB or even 50KB might make sense. But usually messages that big indicate that there is something wrong and you should review what you are doing and reconsider your options.

Which data should be sent reliably and which should be sent unreliably?

First of all, you should know reliability is an option only when the protocol used is UDP. TCP has its own "reliability" mechanism(s) which are not covered here.

Sending something reliable means that we should make sure it arrives to target(s). So in case we do not receive an acknowledgment after waiting enough time, we repeat sending until we receive the acknowledgment or we exceed the number of retrials. Also, repeating reliable events may cause extra latency and make subsequent events delayed.

Examples for not using reliability:

  • player position updates in realtime games
  • voice or video chat

Example for using reliability:

  • turn events in turn-based games

Why do I have so many disconnects in my game?

The disconnects could be due to various reasons. We already have this documentation page that can help you investigate the related issues: "Analyzing Disconnects".

How messages per second per room are calculated?

Photon server counts total inbound and outbound messages every second and divide it by the total number of rooms (on the same Master Server).

Any operation request or operation response or event is considered a message. Photon operations return an optional operation response and trigger zero or more events. Cached events are also counted as messages.

Messages cost per in-room operation:

Operation Success: Best Case Success: Average Case Success: Worst Case
Create 2
(SuppressRoomEvents=true)
3
+ Join event (SuppressRoomEvents=false, default)
3
Join 2 + k
(SuppressRoomEvents=true)
+ k * cached custom event
2 + n + k
+ n * Join event (SuppressRoomEvents=false, default)
2 + 2 * n + k
+ n * ErroInfo event (HasErrorInfo=true)
Leave 2
(SuppressRoomEvents=true)
1 + n
+ (n - 1) * Leave event (SuppressRoomEvents=false, default)
2 + (n - 1) * 2
+ (n - 1) * ErroInfo event (HasErrorInfo=true)
RaiseEvent 1
(no operation response)
(target: interest group with no subscribers)
1 + n
+ n * custom event
(target: all/broadcast)
2 + 2 * n
+ n * ErroInfo event (HasErrorInfo=true)
+ Auth event (token refresh)
SetProperties 2
Broadcast=false
2 + n
+ n * PropertiesChanged event (default: Broadcast=true, BroadcastPropertiesChangeToAll=true)
2 + 2 * n
+ n * ErrorInfo event (HasErrorInfo=true)
+ 1 in case of CAS or BroadcastPropsChangeToAll

How do I calculate traffic consumed by a user?

This is a complex topic. First you need to know that any calculation done is just a theoretical estimation and may not reflect reality. We recommend building a Proof-of-Concept and use it to gather real data.

That being said here is how to estimate traffic generated by a single user inside a room:

Let's assume the following:

  • a room has N players.
  • a player sends F messages per second (message send rate in Hz)
  • average message size is X (in bytes, payload (P) + protocol overhead (O))
  • an average player spends H hours per month on your game

If we do not consider ACKs, connection handling (establishment, keep alive, etc.) commands and resends. Then we say that on average, a CCU consumes C (in bytes/month) in your game as follows:

C = X * F * N * H * 60 (minutes per hour) * 60 (seconds per minute)

How to quickly rejoin a room after disconnection?

To recover from an unexpected disconnection while joined to a room, the client can attempt to reconnect and rejoin the room. We call this a "quick rejoin". A quick rejoin will succeed only if:

  • the room still exits on the same server or can be loaded: If a player leaves a room, the latter can stay alive on Photon server if other players are still joined. If the player is the last one to leave and the room becomes empty then the EmptyRoomTTL is how long it will remain alive waiting for players to join or rejoin. If after EmptyRoomTTL the room is still empty and no one joined then it will be removed from Photon server. If persistence conditions are met and webhooks are setup, the room state can be saved on the configured web service to be loaded later.
  • the actor is marked as inactive inside: an actor with the same UserId exists inside the actors' list but not currently joined to the room. This requires PlayerTTL to be different from 0.
  • the PlayerTTL for the inactive actor did not expire: when an actor leaves a room with the option to come back we save his Deactivation timestamp. As long as the room is alive, if PlayerTTL milliseconds are elapsed after Deactivation time the respective actor is removed from the actors' list. Otherwise, when the actor tries to rejoin, if the difference in milliseconds between the time of the rejoin attempt and Deactivation time exceeds PlayerTTL then the actor is removed from the actors' list and the rejoin fails. So an inactive actor can rejoin a room only for PlayerTTL milliseconds after Deactivation time.

In PUN you can call PhotonNetwork.ReconnectAndRejoin().

PUN

What is the difference between PUN Plus and PUN Free?

The content of the packages is identical but with the purchase of PUN Plus you get a voucher for a 100 CCU Photon Cloud Subscription that is valid for 12 months from the time of redeeming it.

It's a really good deal as 100 CCU are in average sufficient for 2.000 DAU and 40.000 MAU (these numbers are averages across all games that run in our Cloud).

Please note that you must redeem the code in your dashboard within 12 months after the purchase date.

How To Redeem The PUN Plus Voucher?

  1. Open your Photon Dashboard.
  2. For the App Id you intend to apply the voucher to select -/+ CCU.
  3. Select the 100 CCU tab
  4. Click "Got a Voucher? Add plan using your coupon code..." and enter your invoice id (not order nr.)
  5. Enter your Unity invoice number in the "Coupon Code or Unity Invoice No." field. You get the Unity invoice number once you purchase PUN Plus for the Unity Asset Store. Do not use the order number.
  6. Double check the application ID and Click "REDEEM".

Why Do I Have So Much Lag In My Game?

If you have infrequent ping (RTT) issues, it's hard to tell what actually happens in those cases. Aside from the game and PUN itself, it can also be related to network issues. The infrastructure is often very complex and hard to control. Some messages in PUN are reliable (e.g. RPCs) and when those get lost, they need to be resent. If this happens more than once, the ping will go up quickly and the in-game logic stalls due to lack of updates.

PUN has features to fight lag due to resends but it can't avoid it entirely. Always make sure to update to the latest version.

Lag could lead to disconnects. You can have a look at the common solutions to disconnects described here.

If you think we should take a closer look at your case, we need to know how to reproduce it, the frequency it happens with, when and for how long. Ideally, you already tried this on more than one connection and connection type and on more than one specific device - let us know on which.

Provide us the details described here.

If there is anything we can reproduce, we will try to find a solution to it.

What PUN Version Am I Using?

PUN version can be obtained in 3 different ways:

  • inside the Unity Editor, from PhotonServerSettings inspector, it's mentioned on the top.
  • from PhotonNetwork.PunVersion string field.
  • from "Assets\Photon\PhotonUnityNetworking\changelog.txt", check the first entry on top.

Billing

Do you have special offers for students, hobbyists or indies?

All our products have a free tier and a one-off entry-plan. We also usually take part in Unity's asset store sales and occasionally give vouchers to lucky ones.

Can I combine more than one 100 CCU plan for a single Photon application?

No. The 100 CCU plans are not stackable and can be applied only once per AppId. If you purchase multiple PUN+ asset seats then you must redeem each 100 free CCU for a separate AppId. If you need more CCU for a single app, the next higher plan is the 500 CCU one. If you subscribe to a monthly or yearly plan, then you will still keep the 100 CCUs for 12 months on top of / in addition to the CCU from your monthly/yearly plan.

Back to top