set up matlab job scheduler cluster for auto-凯发k8网页登录

main content

set up matlab job scheduler cluster for auto-resizing

you can customize your matlab® job scheduler (mjs) cluster to resize automatically. by default, an mjs cluster does not have the resizing functionality enabled. this means that mjs immediately rejects any work you submit to the cluster that requires more than the current number of workers in the cluster. auto-resizing, also called auto-scaling, allows you to submit such work to the cluster and makes the number of workers in the cluster change automatically with the amount of work submitted. the cluster grows (scales up) when there is more work to do and shrinks (scales down) when there is less work to do. this allows you to use your compute resources more efficiently and can result in cost savings.

to configure your mjs cluster to resize automatically, you need to:

  1. set the maximum number of workers in the mjs_def file.

  2. start an mjs cluster.

  3. set up an auto-resizing process.

set maximum number of workers

to make an mjs cluster resizable, you need to define the maximum number of workers of your cluster by editing the mjs_def file as follows:

  1. open the file mjs_def.sh (on linux®) or mjs_def.bat (on windows®) located at matlabroot/toolbox/parallel/bin, where matlabroot is the directory of your matlab installation.

  2. uncomment one or both of the lines #max_linux_workers= and #max_windows_workers= and set them to the desired values. these variables define the maximum number of linux and windows workers to which you can resize the cluster, respectively.

a resizable mjs cluster allows jobs in the queue that require more than the current number of workers in the cluster, up to the amount specified in max_linux_workers and max_windows_workers. other jobs are cancelled immediately.

note

to change the maximum number of linux and windows workers after the cluster has started, use the resize script located at matlabroot/toolbox/parallel/bin to run the resize update command. for example:

% cd matlab/toolbox/parallel/bin
% ./resize update -jobmanager myjobmanager -maxlinuxworkers 4 -maxwindowsworkers 8

start mjs cluster

to create a cluster with the options defined in the mjs_def file, start an mjs cluster after editing and saving this file. for more information about how to install, configure and start an mjs cluster, see .

set up auto-resizing process

to make a resizable mjs cluster change size automatically, you must set up a background process to periodically adjust the size of the cluster. the specific implementation of this background process depends on many factors, but you can follow these general recommended steps:

  1. identify the desired size of the cluster. the desired size of a resizable mjs cluster is reported as the total number of workers for each operating system and hence includes all busy workers and some idle workers that are already in the cluster. the desired size changes based on running jobs and jobs in the queue. use the resize script located at matlabroot/toolbox/parallel/bin to run the resize status command:

    % cd matlab/toolbox/parallel/bin
    % ./resize status
    the resize status command above returns information about the resizable cluster in json format:
    {
      "jobmanagers": [
        {
          "name": "myjobmanager",
          "host": "myhostname",
          "desiredworkers": {
            "linux": 1,
            "windows": 0
          },
          "maxworkers": {
            "linux": 4,
            "windows": 8,
          },
          "workers": [
            {
              "name": "worker_1",
              "host": "myhostname",
              "operatingsystem": "linux",
              "state": "busy",
              "secondsidle": 0
            },
            {
              "name": "worker_2",
              "host": "myhostname",
              "operatingsystem": "linux",
              "state": "idle",
              "secondsidle": 60
            }
          ]
        }
      ]
    }
    parse the json output to extract the desiredworkers values that represent the desired number of linux and windows workers for the mjs cluster.
  2. compare the desired number of workers with the workers in the cluster to decide whether you need to start or stop workers. use the workers array in the output of the resize status command to examine the workers in the cluster. to ensure that jobs in the queue eventually run, you must start enough workers to match or exceed the desired number of workers. you can optionally stop idle workers that exceed the desired number of workers.

    note

    if workers take a long time to start in your environment, you might want to wait for excess workers to be idle for some time before stopping them. this approach can be more efficient than immediately stopping excess idle workers if they are needed again soon after they become idle. to check how long a worker has been idle, examine the secondsidle value for the worker.

  3. start or stop workers as necessary. to do this, use the and utility scripts. to avoid interrupting any work when stopping workers, it is recommended that you use the -onidle flag with the command.

see also

| |

related topics

    网站地图