Skip to content
Cloud & DevOps

IBM Spectrum LSF Explained: Architecture, Installation and Job Scheduling

A practical guide to IBM Spectrum LSF: what it does, how its daemons work together, how to install a cluster on Linux, how to submit and monitor jobs, and how queues share servers fairly.

7 min read
Illustration: a cluster of servers running scheduled jobs

Imagine an engineering team with twenty powerful servers and fifty people who need them. Without a scheduler, everyone logs in to a favourite machine. A few servers are overloaded, others sit idle, and one heavy simulation can slow down everybody else's work.

IBM Spectrum LSF (Load Sharing Facility) solves this problem. Users describe what a job needs, such as CPU cores, memory, a GPU or a time limit. LSF then decides where and when the job runs. It is used for high-performance computing (HPC), including chip design, engineering simulation and research.

This guide covers how LSF works, how to install it on Linux, and the commands that users and administrators need most. It is based on LSF 10.1.

Key terms

TermMeaning
ClusterA group of servers that LSF manages together.
Management hostThe server that accepts jobs and makes scheduling decisions. Older documents call it the master host.
Server hostA server that runs jobs.
JobA command or script submitted to LSF.
QueueA waiting line for jobs, with its own priority, limits and rules.
Job slotA unit of capacity on a host. LSF uses slots to decide how many tasks a host can run.

How LSF works

Diagram: users submit jobs to the LSF management host, which dispatches them to server hosts and receives load information back
How the parts of an LSF cluster work together.

LSF is a set of background services, called daemons, that run on the hosts:

DaemonRuns onWhat it does
mbatchdManagement hostAccepts jobs, keeps them in queues and dispatches them.
mbschdManagement hostDecides which job runs where.
sbatchdEvery server hostStarts jobs on its host and reports their status.
limEvery server hostCollects load and configuration information.
resEvery server hostHandles requests to run tasks remotely.
pimEvery server hostMeasures the CPU and memory that job processes use.

If the management host fails, another host from the configured list can take over. This only works if that host can read the same LSF configuration and working files, which is why they are normally kept on reliable shared storage.

The life of a job

Diagram: an LSF job moves from PEND to RUN and ends as DONE or EXIT, with PSUSP, USUSP and SSUSP as suspended states
The states a job can pass through.
  • PEND: waiting in a queue.
  • RUN: running on a host.
  • DONE: finished successfully, with exit code 0.
  • EXIT: ended with an error, or was killed.
  • PSUSP: suspended by its owner or an administrator while it was still waiting.
  • USUSP: suspended by its owner or an administrator after it started.
  • SSUSP: suspended by LSF after it started, for example because the host was overloaded.

Installing LSF on Linux

LSF is commercial software. You need the installer, the package for your platform and an entitlement file from IBM. IBM has also offered a free Community Edition with limits on cluster size, so check IBM's current terms before you plan around it.

1. Prepare the hosts

  • Make sure every host can resolve the names of all the others.
  • Keep the clocks in sync with NTP or chrony.
  • Use the same user accounts and user IDs on every host.
  • Mount a shared directory, such as NFS, at the same path on every host.
  • Create an administrator account, for example lsfadmin. The primary administrator cannot be root.
  • Allow LSF traffic between the hosts, but never expose LSF ports to the internet.

2. Edit install.config

Extract the installer and set these values in install.config. Do not put spaces around the equals sign. The names and paths here are examples:

LSF_TOP="/shared/lsf"
LSF_ADMINS="lsfadmin"
LSF_CLUSTER_NAME="cluster1"
LSF_MASTER_LIST="mgmt01 mgmt02"
LSF_ADD_SERVERS="node01 node02 node03"
LSF_TARDIR="/shared/lsf_packages"
LSF_ENTITLEMENT_FILE="/shared/lsf_packages/lsf.entitlement"

The first name in LSF_MASTER_LIST becomes the management host. The others can take over if it fails.

3. Install and start the cluster

Run the installer as root:

./lsfinstall -f install.config

Then run this as root on every LSF host, so the daemons start when the server boots:

cd /shared/lsf/10.1/install
./hostsetup --top="/shared/lsf" --boot="y"

Finally, load the LSF environment and start the daemons on all hosts:

. /shared/lsf/conf/profile.lsf
lsfstartup

lsfstartup needs remote access to the other hosts. To make it use SSH, set LSF_RSH=ssh in lsf.conf.

4. Check that it works

lsid            # LSF version, cluster name and management host
lshosts         # hosts and their hardware
bhosts          # which hosts can accept jobs
bsub sleep 60   # submit a test job
bjobs           # see its status

Submitting jobs

Jobs are submitted with bsub. For anything you run more than once, put the options in a script:

#!/bin/bash
#BSUB -J simulation
#BSUB -q normal
#BSUB -n 8
#BSUB -R "span[hosts=1] rusage[mem=4GB]"
#BSUB -W 2:00
#BSUB -o simulation.%J.out
#BSUB -e simulation.%J.err

./run_simulation

Submit it with the < sign, so that LSF reads the #BSUB lines:

bsub < simulation.sh
OptionMeaning
-JJob name.
-qQueue to use.
-n 8Number of tasks, which normally means eight job slots.
span[hosts=1]Keep all the tasks on one host.
rusage[mem=4GB]Reserve memory for the job.
-W 2:00Time limit of two hours.
-o, -eFiles for output and errors. %J becomes the job ID.

Watch the memory value. Depending on how your cluster is configured, rusage[mem] can count once per host or once for every task. Eight tasks with 4 GB each would reserve 32 GB. Ask your administrator which rule applies.

Useful patterns

Job array: run the same test 500 times with different inputs, with at most 50 running at once.

bsub -J "regress[1-500]%50" -o "regress.%J.%I.out" './run_test $LSB_JOBINDEX'

Dependency: start the tests only after the build succeeds.

bsub -J build ./build.sh
bsub -w 'done("build")' ./test.sh

GPU job:

bsub -gpu "num=1" python train.py

Interactive shell on a server host:

bsub -Is bash

Monitoring and controlling jobs

CommandUse it to
bjobsList your unfinished jobs. Add -u all to see everyone's.
bjobs -l JOBIDSee full details of one job.
bjobs -pSee why jobs are still waiting.
bpeek JOBIDRead the output of a running job.
bhist -l JOBIDSee the history of a job.
bacctSee statistics for finished jobs.
bstop, bresumeSuspend a job, then continue it.
bkill JOBIDStop a job for good.
bqueues, bhosts, lsloadCheck queues, hosts and current load.

Queues and scheduling policies

Queues are where LSF follows your business priorities. They are defined in the file lsb.queues:

Begin Queue
QUEUE_NAME  = normal
PRIORITY    = 30
FAIRSHARE   = USER_SHARES[[design, 3] [verification, 2] [default, 1]]
RUNLIMIT    = 4:00 24:00
DESCRIPTION = Everyday jobs
End Queue

Begin Queue
QUEUE_NAME  = urgent
PRIORITY    = 60
PREEMPTION  = PREEMPTIVE[normal]
DESCRIPTION = Deadline work
End Queue

In this example, design and verification are user groups that must already exist. The two run limits are the default (4 hours) and the maximum (24 hours). Check the file for mistakes, then apply it:

badmin ckconfig
badmin reconfig

Fairshare

Diagram: shares of 3, 2 and 1 give three busy groups about 50, 33 and 17 percent of the cluster
Shares of 3, 2 and 1 while all three groups have jobs waiting.

With simple first-come, first-served scheduling, one person can submit a thousand jobs and block everyone else. Fairshare gives each user or group a share of the cluster. Those who have recently used less than their share move ahead. If only one group has work, it can use the free capacity, so servers are not left idle.

Preemption

Jobs in a preemptive queue can take slots from running jobs in a lower-priority queue. By default the lower-priority job is suspended and continues later. A suspended job can still hold memory and software licences, so test this policy before relying on it.

Backfill

Diagram: two short jobs run on idle hosts before a large job that needs all four hosts starts
Backfill: short jobs use hosts that would otherwise sit idle until the large job starts.

A large job may have to wait until enough hosts are free. Backfill lets short jobs run in that gap, as long as they will finish before the large job is due to start. LSF can only plan this when jobs have run limits, so encourage users to set a realistic -W value.

Solving common problems

ProblemWhere to look
A job stays in PENDRun bjobs -l JOBID and read the pending reason. Often the job asks for more memory or cores than any host has free.
A job ends with TERM_MEMLIMITIt used more memory than its limit. Check actual use with bjobs -l, then request more.
A job ends with TERM_RUNLIMITIt reached its time limit. Increase -W or use a queue for longer jobs.
A host accepts no jobsRun bhosts -l HOST. The host may be full, closed by an administrator or unreachable.
Commands cannot contact LSFCheck that profile.lsf is loaded and the daemons are running, then check host names and the firewall.

Good habits for administrators

  • Start with two or three queues. Add more only when there is a clear need.
  • Set default run limits and memory limits, so one faulty job cannot take over a host.
  • Close a host with badmin hclose before maintenance, let its jobs finish, and reopen it with badmin hopen.
  • Back up the LSF configuration directory and record every change.
  • Compare requested and used resources regularly. Jobs that request far more than they use keep other people waiting.

Do you need LSF?

LSF makes sense when many people share many servers, when jobs run for hours, or when expensive software licences must be used well. For one or two servers, cron or a simple job queue is usually enough. If you need a cluster scheduler without licence costs, also compare Slurm, a widely used open-source alternative.

Planning a Linux cluster, or trying to get more from the servers you already have? Book a free consultation and tell us about your workload.

Sources and further reading

IBM and IBM Spectrum LSF are trademarks of International Business Machines Corporation. This is an independent guide and is not endorsed by IBM.

Enjoyed this article?

Get new insights delivered to your inbox.