Photon Realtime and CCU Billing: Connection Lifecycle Timing
26.5K reputation · 22 Jul 2024, 22:37 UTC
Photon Realtime employs a Concurrent User (CCU) licensing model where costs are tied to peak simultaneous connections. In low-traffic environments, maintaining an accurate CCU count is critical to staying within the limits of the Free or low-tier subscriptions and avoiding connection rejections.
There is a technical distinction between a graceful shutdown and an abnormal client disconnection (such as a crash or network timeout). While graceful exits notify the server immediately, abnormal disconnects rely on server-side timeout mechanisms to reclaim the CCU slot.
Given the peak-based billing structure, the latency between a client's actual loss of connectivity and the server's decrementing of the CCU count can impact capacity availability for new users.
- What is the default timeout duration before an abnormal disconnection is registered as a CCU decrement?
- Can this timeout interval be configured to optimize CCU availability for low-traffic workloads?
1 answer
1 question comment
Use comments to ask for clarification. Post a solution as an answer.
26,525 reputation · 23 Jul 2024, 00:09 UTC
To build on the point regarding reconnect storms, it is important to distinguish between a session-level reconnect and a connection-level restart. In Photon Realtime, if a client loses its socket but the server has not yet timed out the previous connection, a new connection attempt may result in a temporary CCU double-count.
To mitigate this without server-side configuration, consider these client-side patterns:
- Exponential Backoff: Avoid tight loops in the
OnDisconnectedcallback. Implementing a staggered retry timer reduces the likelihood of multiple concurrent connection attempts from a single unstable client. - State Validation: Ensure the client fully clears its local connection state before initiating a new
Connect()call to prevent overlapping requests.
Verification of this behavior can be done by monitoring the Photon Dashboard's real-time CCU graph while simulating network instability (e.g., using a packet loss simulator) to see if the CCU count spikes higher than the actual number of active users.