MATLAB Help Center
You can customize your MATLAB® Job Scheduler cluster to resize automatically based on demand. By default, an MATLAB Job Scheduler cluster does not have the resizing functionality enabled. This means that MATLAB Job Scheduler 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 MATLAB Job Scheduler cluster to resize automatically, you need to:
Set the maximum number of workers in the mjs_def file.
mjs_def
Start an MATLAB Job Scheduler cluster.
Set up an auto-resizing process.
To make an MATLAB Job Scheduler cluster resizable, you need to define the maximum number of workers of your cluster by editing the mjs_def file as follows:
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.
mjs_def.sh
mjs_def.bat
matlabroot/toolbox/parallel/bin
matlabroot
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.
#MAX_LINUX_WORKERS=
#MAX_WINDOWS_WORKERS=
A resizable MATLAB Job Scheduler 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 canceled immediately.
MAX_LINUX_WORKERS
MAX_WINDOWS_WORKERS
Tip
In the mjs_def file, you can also specify a scheduling algorithm that works well with a resizable MATLAB Job Scheduler cluster, such as the standard scheduling algorithm. For more details, see the definition for the SCHEDULING_ALGORITHM parameter in Define MATLAB Job Scheduler Startup Parameters.
standard
SCHEDULING_ALGORITHM
To create a cluster with the options defined in the mjs_def file, start an MATLAB Job Scheduler cluster after editing and saving this file. For more information about how to install, configure and start an MATLAB Job Scheduler cluster, see Install for MATLAB Job Scheduler with Network License Manager.
Note
To change the maximum number of Linux and Windows workers after you start the cluster, use the resize script located at matlabroot/toolbox/parallel/bin to run the resize update command. For example:
resize
resize update
% cd matlabroot/toolbox/parallel/bin % ./resize update -jobmanager myJobManager -maxlinuxworkers 4 -maxwindowsworkers 8
To make a resizable MATLAB Job Scheduler 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:
Identify the desired size of the cluster. The desired size of a resizable MATLAB Job Scheduler 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:
resize status
% cd matlab/toolbox/parallel/bin % ./resize status
{ "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 } ] } ] }
desiredWorkers
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.
workers
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.
secondsIdle
Start or stop workers as necessary. To do this, use the startworker and stopworker utility scripts. To avoid interrupting any work when stopping workers, it is recommended that you use the -onidle flag with the stopworker command.
startworker
stopworker
-onidle
startworker | stopworker | mjs
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
Europe
Asia Pacific
Contact your local office