Move Sessions Between Clusters

This section explains how to move sessions between clusters in an AWS deployment.

In situations where worker clusters can be dynamically started and stopped, you may want to move sessions between clusters to better manage the loads on the clusters. You can move sessions between clusters manually using CONTROL MOVE SESSION or automatically using a scaling policy.

Multiple clusters are not supported in on-premises installations.

Auto scaling policy

Auto scaling allows sessions to be automatically distributed across a number of clusters in a cluster resource group, using a scaling policy that determines on which cluster to run a session based on different criteria. The clusters and the scaling policy are specified in JSON format using the ALTER SYSTEM command with the AUTO_SCALING_POLICY parameter.

JSON format details

version (number): The version number of the JSON syntax format. Currently, only version 1 is supported.

clusterResourceGroups (array): A list of cluster resource groups. Currently, only one group is supported.

  • groupId (string): A user-defined ID for the cluster resource group. The group ID can be set freely.

  • clusters (array): A list of the clusters in the group. For each cluster, set the following parameters:

    • clusterId (string): The name or UID of a cluster. Either is accepted.

    • weight (number): The preference for a given session to run on a certain cluster relative to the other clusters in the group.

      • The higher the weight of a cluster, the more likely it is that a session will be routed to that cluster.

      • Weights are normalized over the clusters, and the absolute values of the weights are not directly relevant. For example, the effect of clusters A and B having weights 1 and 2, respectively, is exactly the same as if the weights were 50 and 100.

  • scalingPolicy (string): Specifies the scaling policy that should be used in order to distribute the sessions among the clusters. Select one of the following policies:

    • session-round-robin: Sessions are distributed among clusters in a round-robin fashion.

      The weight of a cluster is ignored in this case. By definition, round-robin distributes the sessions sequentially and uniformly.

    • session-autobalance: Balances sessions based on the total number of connected sessions to a cluster – not the number of active sessions.

    • session-weighted: Balances sessions based on a weighted probability distribution specified by the weight set for each cluster.

Example:
ALTER SYSTEM SET AUTO_SCALING_POLICY =
'{
    "version": 1,
    "clusterResourceGroups": [
        {
            "groupId": "default",
            "clusters": [
                { "clusterId": "cluster1", "weight": 10 },
                { "clusterId": "cluster2", "weight": 20 }
            ],
            "scalingPolicy": "session-autobalance"
        }
    ]
}'

Move session to worker cluster

You can specify a single session, a comma-separated list of sessions, or all inactive sessions to be moved to a worker cluster using the CONTROL MOVE SESSION command. The sessions must have been initiated on the main cluster. If a session was initiated on the main cluster and then moved to a worker cluster, it can however be moved again to another worker cluster.

You can specify a timeout value in seconds. If a session is not moved within the timeout, an exception is thrown for this session. Optionally, all currently running statements can be forcibly killed on sessions that cannot be moved within the timeout.

Clusters can be specified by cluster name or cluster UID.

  • To determine the current cluster name for the current session, use SELECT CURRENT_CLUSTER;
  • To determine the current cluster name for all other sessions, use SELECT CLUSTER_NAME, SESSION_ID FROM EXA_DBA_SESSIONS;
  • To determine the current cluster UID for a session, use SELECT CURRENT_CLUSTER_UID;
  • To determine the cluster names, use SELECT CLUSTER_NAME FROM EXA_CLUSTERS;
Example:

To move two sessions from the main cluster to a worker cluster:

CONTROL MOVE SESSION 1234567890123456788, 1234567890123456789 TO 'WORKER1' WAIT TIMEOUT 60 FORCE;

For more details and examples, see CONTROL MOVE SESSION.