Migration
Overview
This page describes the behavior of migration on Diarkis servers.
What is Migration?
Diarkis servers are configured in a cluster, and users are connected to one of the servers within the cluster. Consider a scenario where the connected Diarkis server scales in and the server that the user is connected to stops. Ordinarily, if a server stops, the users connected to it would be disconnected. However, Diarkis servers can move to another server within the cluster, continuing to provide the service without disconnecting the user.
This mechanism of maintaining service by reconnecting from the current server to another server is called migration.
While the explanation uses scaling in as an example, migration can occur for various other reasons beyond just scaling in. When migration occurs, the server and client application need to coordinate to proceed with the migration process. The next section explains the specific procedures that take place when migration occurs.
If you are participating in a Room, please refer to the Room-specific migration instead of the functionalities described below.
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 reasons, it notifies the client of the need for migration, triggering DiarkisTcpBase::OnOffline
/ DiarkisUdpBase::OnOffline()
. Upon receiving this event, which indicates the necessity of migration, the client executes DiarkisTcpBase::SendMigrate()
/ DiarkisUdpBase::SendMigrate()
to request the server to start migrating. The server, upon receiving the migrate request, disconnects the client, transfers the user's data on the server to the new target server, and then the client reconnects to the new server.
This sequence of processes takes place 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, it is implemented to call SendMigrate()
immediately after OnOffline()
is triggered, as shown below:
Note that executing DiarkisTcpBase::SendMigrate()
/ DiarkisUdpBase::SendMigrate()
to initiate the reconnection process will temporarily disable communication as the connection to the server is disconnected briefly. The timing of this disconnection can be controlled by the timing of executing DiarkisTcpBase::SendMigrate()
/ DiarkisUdpBase::SendMigrate()
, so adjust it according to your application's needs.
最終更新