Main Content

Enable High Availability in MATLAB Online Server

MATLAB® Online Server™ is deployed as a collection of microservices on a Kubernetes® cluster. Because these services are stateless, maintaining state through cookies and communicating with each other, all their data is stored in memory and not backed up. If a pod restarts or fails, MATLAB users might need to sign in again. To prevent this behavior, you can enable high availability (HA) for the server.

In an HA environment, MATLAB Online Server replicates each pod running an individual service. If one pod fails, the server switches to a replicated pod to keep the server running. This improved reliability comes at the expense of using additional computing resources.

Although you can enable HA for MATLAB Online Server regardless of the underlying Kubernetes infrastructure, your production environment should have a highly available Kubernetes cluster. For information on creating a highly available cluster, see the Kubernetes documentation for your provider.

How Services Work in High Availability Environment

MATLAB Online Server runs these core services:

  • AuthNZ — Authentication

  • Core-UI — UI-related files

  • Gateway — Proxies the requests to the appropriate resource

  • MATLAB Pool — Remote MATLAB resources

  • Resource — Acquires the MATLAB resource for the user

Although MATLAB Online Server services are stateless, by default the AuthNZand Gateway services store in-memory information about logged-in users and the mapping between user sessions and their respective MATLAB instances. When HA is enabled, for these services, MATLAB Online Server starts four pods (two AuthNZ pods, two Gateway pods) of a Redis™ service that works as a highly available cache. In this configuration, a failure of a single AuthNZ or Gateway pod does not affect stored information about current sessions and their mapped tokens and MATLAB instances. When a Kubernetes cluster has multiple worker nodes, MATLAB Online Server pods are configured to be spread across several nodes using anti-affinity.


High availability does not affect the persistence of MATLAB code and data that users write, store, and execute on the server. To enable users to save data between session, you can mount persistent, individualized folders for them. For details, see Configure File Storage for Users in MATLAB Online Server.

Because the core services start as single pods, MATLAB Online Server is not highly available by default. When you enable HA, the server replicates these pods, either in a local Redis cache server or an external Redis server.

Enable High Availability Using Local Redis Cache (Default)

To enable the default HA configuration for MATLAB Online Server, where the server replicates pods in a local Redis cache server, follow these steps.

  1. In the install.config file of your MATLAB Online Server installation folder, set the IS_HA_ENABLED property to true. With this setting, the generated overrides for each MATLAB Online Server service have a replica count set to 2.

  2. Copy the Helm® charts to add the Redis pod to the updated MATLAB Online Server configuration.

    sudo ./mosadm copy-helm-charts
  3. Generate the new YAML override files, skipping the MATLAB image.

    sudo ./mosadm generate-overrides --skip-matlab-image
  4. Undeploy and redeploy the server.

    ./mosadm undeploy
    ./mosadm deploy

Enable High Availability Using External Redis Server

To use an external Redis server to enable HA, then you must first disable the local Redis deployment and then manually configure the external deployment in the appropriate YAML override files.

  1. In the install.config file, set IS_HA_ENABLED to true, and add the DEPLOY_REDIS property and set it to false.


  2. Copy the Helm charts to add the Redis pod to the updated MATLAB Online Server configuration.

    sudo ./mosadm copy-helm-charts
  3. Generate the new YAML override files, skipping the MATLAB image.

    sudo ./mosadm generate-overrides --skip-matlab-image
  4. (Optional) If you are deploying MATLAB Online Server on Red Hat® OpenShift®, then you must also add the following lines to the generated ./overrides/cluster/namespace/redis.yaml file.

      create: false
      name: "custom-sa"

    The custom-sa field value is a service account that is created following these instructions for installing MATLAB Online Server on Red Hat OpenShift.

    oc create sa custom-sa --namespace your-namepsace
    oc adm policy add-scc-to-user privileged -z custom-sa --namespace your-namespace
  5. Open the authnz.yaml and gateway.yaml override files.

    • ./overrides/cluster/namespace/authnz.yaml

    • ./overrides/cluster/namespace/gateway.yaml

  6. In these files, locate the kv section. The default kv section enables MATLAB Online Server to generate a Redis configuration with the type FailoverRedis in those two files.

      type: "FailoverRedis"
        mastername: "redis-sentinel-master"
        addrs: "mathworks-redis:26379"

    The FailoverRedis cache type enables communication with the Redis server deployed within MATLAB Online Server, using the configuration specified under failoverredis.

  7. Update the cache type and configuration for your external Redis server. Specify one of these configurations.

    • BasicRedis — Single Redis instance, where all items are stored in the same instance.

        type: "BasicRedis"
          addr: "your-redis-server:your-redis-port"
          tls: true
          password: "your-redis-password"
    • ClusterRedis — Multiple Redis instances, where items are sharded across all instances and each instance has only a subset of items.

        type: "ClusterRedis"
          addrs: "your-redis-server:your-redis-port"
          tls: true
          password: "your-redis-password"

      The addrs field, under the ClusterRedis type, can be assigned to a single server:port value or to multiple comma-separated server-i:port-i values.


    Not all Redis configurations provided by cloud platforms support HA by default. If you are using an external Redis server, use one with an HA configuration enabled. For secure communication with any external Redis server, you must set the tls field to true.

  8. To apply your changes, undeploy and redeploy the server.

    ./mosadm undeploy
    ./mosadm deploy

Related Topics

External Websites