Migration
Overview
This page describes the behavior of migration on Diarkis servers.
What is Migration?
Diarkis servers are configured in a cluster, and users connect to one of these servers. Consider a scenario where the connected Diarkis server is scaled in and the server to which the user is connected is shut down. For a typical server, users connected at that time would be disconnected because the server stops. However, Diarkis servers can move within the cluster, allowing users to continue receiving services without disconnection. This mechanism, where the service is maintained by reconnecting from the server currently connected to another server, is called migration.
While we explained it using the example of scaling-in for simplicity, migration can occur due to various factors besides scaling-in. When migration occurs, the server and client application need to collaboratively proceed through the migration process. The following sections explain the specific processes when migration occurs.
If you are participating in a Room, please do not use the features below and refer to the Room-specific migration.
Overall Flow of the Migration Process
Migration begins with a notification from the server.
When the server determines that migration is necessary due to various factors, it notifies the client of the need for migration, triggering DiarkisTcpBase::OnOffline
/DiarkisUdpBase::OnOffline()
. Upon receiving this event, which indicates that migration is necessary, the client executes DiarkisTcpBase::SendMigrate()
/DiarkisUdpBase::SendMigrate()
to request the initiation of migration from the server. Once the server receives the migration request, it disconnects the requesting client, moves the user's data on the server to a new server, and the client reconnects to the new server.
These processes are undertaken during migration.
Client Response During Migration
As explained in the previous section, on the client side, after receiving DiarkisTcpBase::OnOffline
/DiarkisUdpBase::OnOffline()
, it is necessary to proceed with the migration process by executing DiarkisTcpBase::SendMigrate()
/DiarkisUdpBase::SendMigrate()
.
In the sample provided with the SDK, SendMigrate()
is implemented to be called immediately after OnOffline()
is triggered, as shown below:
Note that when executing DiarkisTcpBase::SendMigrate()
/DiarkisUdpBase::SendMigrate()
, the reconnection process starts, temporarily disabling communication as the connection to the server is disconnected briefly. The timing of disconnection can be controlled by the timing of executing DiarkisTcpBase::SendMigrate()
/DiarkisUdpBase::SendMigrate()
, so please adjust it according to your application's needs.
Last updated
Was this helpful?