Best practices for handling Video API server rotations.
Modern cloud auto-scaling makes it necessary to establish a minimum rotation time for services. Sessions lasting more than 8 hours might be disconnected, as they may reside in services that are scaling out or scaling in.
You can register a callback URL for session events to be sent to your callback URL. When a group of Video API servers for one of your sessions is scheduled to be rotated, a sessionNotification
event is sent to your registered callback endpoint.
See the Session Monitoring documentation.
If clients remain connected to a session when set of servers shut down because of server rotation, a sessionDestroyed
event is set to your callback URL. The reason
property of the sessionDestroyed
event is set to "serverRotation"
. And each connected client is disconnected from the session and receives a sessionDestroyed
event.
There are steps you should take in response to a sessionNotification
event to keep clients connected. (See the next section.)
When the servers for the session are rotated (one hour after the session notification event is sent), clients connected to the session using those servers will be forced to disconnect from the session. When your application server receives a server rotation session notification callback, it should take action to reconnect the clients to a new session:
Create a new Video API session using the Video API REST API or a Video API server SDK.
Send the session ID for the new session to the clients connected to the session. You may want to use the Video REST API or a Video API server SDK to send the signal to the connected clients. See this documentation.
The clients should immediately disconnect from the original session and reconnect to the new session.
For a more seemless transition between sessions and to minimize any potential reconnection time, clients can remain connected to the initial session and switch the video display before disconnecting from the initial session (upon connecting to the new session).
What is Video API server rotation? How frequently are Video API servers updated?
Software cloud scalability requires a continuous ability to rotate servers. Vonage maintains an 8-hour window to avoid excessive rotation of long-lived sessions. Rotations can happen daily.
There are a few main reasons for a media server to be rotated. The main reasons are maintenance, software updates, security patching, infrastructure servicing and elastic autoscaling:
Maintenance, security, and new software updates — Services are improved regularly. This can be updates to software, which is less frequent, security patches, or infrastructure updates.
Cloud servicing of troubled systems — Between infrastructure alerts, possible anomalies detection, or infrastructure procedures to refresh cloud systems, systems may be taken automatically out of service, respecting the 8-hour limits, to assure there are no prolonged issues.
Elastic autoscaling — Systems are also regularly spinning up and down to handle loads within regions and handle "follow the sun" capacities. As such, in the long term, lightly loaded servers may be scaled in to consolidate infrastructure.
Can I use the same session ID to reconnect once a session is disconnected due to server rotation?
Using a new session ID is recommended to assure that the new session is directed to a new server instance. If the session is disconnected due to server rotation, all clients will be disconnected. If the same session ID is used, the reconnection will be moved to a new server after the session is terminated, following the sessionDestoryed event.