Back to Knowledege base

Managing System Load with Load Levels

Controlling batch job workload and resource allocation

What Are Load Levels?

Load levels provide fine-grained control over batch job workload. Each job has a load level number representing its resource impact.

Three load level components:

LOADLEVEL (system variable) : Maximum total load allowed for running jobs

CLOAD (system variable, read-only) : Current total load of all running jobs

Job load level : Individual job's load value

Rule: Jobs start only when CLOAD + job_load <= LOADLEVEL

How Load Levels Work

Example:

LOADLEVEL: 20000
CLOAD: 15000

Job A load: 2000  → Can start (15000 + 2000 = 17000 <= 20000)
Job B load: 6000  → Cannot start (15000 + 6000 = 21000 > 20000)

Job B waits until enough jobs complete to reduce CLOAD.

Why Use Load Levels?

Better than simple job count:

Instead of "max 5 jobs", you can say "max 20,000 load units", allowing:

  • 20 small jobs (1000 each) = 20,000
  • 10 medium jobs (2000 each) = 20,000
  • 6 large jobs (3000 each) = 18,000
  • Mix of different sizes totaling <= 20,000

Benefits:

  • Accounts for job size differences
  • More flexible resource management
  • Prevents large jobs from overwhelming system
  • Allows small jobs to slip in alongside large ones

System Load Levels

LOADLEVEL:

Controls maximum workload:

bash

# View current value
btvar -v LOADLEVEL

# Increase to allow more work
btvar -s LOADLEVEL 30000

# Decrease to reduce workload
btvar -s LOADLEVEL 10000

CLOAD:

Shows current workload (read-only):

bash

# View current load
btvar -v CLOAD

# Example output:
# CLOAD    5000    # Current load level

Cannot be modified directly - Xi-Batch updates automatically as jobs start/stop.

Job Load Levels

Each job assigned a load level:

From command interpreter:

bash

# Job inherits interpreter's load level
btr script.sh  # Uses sh interpreter, gets load 1000

Override with special create privilege:

bash

# Set specific load level
btr -l 5000 big-job.sh

Change existing job:

bash

btjchange -l 2000 <job_number>

User Load Limits

Each user has two load level limits:

Maximum load level (maxll):

Largest load any single job can have:

bash

# User's max: 5000
# Cannot create jobs with load > 5000

Total load level (totll):

Maximum combined load of user's running jobs:

bash

# User's total: 10000
# Running jobs:
#   Job A: 3000
#   Job B: 4000
#   Total: 7000 (OK)
# 
# New job: 4000
# Would be: 11000 > 10000 (blocked)

View user limits:

bash

btuser -l <username>

Shows:

Maximum load level: 5000
Total load level: 10000

Load Level Strategy Example

System setup:

LOADLEVEL: 20000  # System maximum

Job types and load levels:

Light reports: 500
Medium processing: 1500
Heavy batch: 5000
Database updates: 3000

Command interpreters:

bash

# Light
Name: reports
Load Level: 500

# Medium
Name: process
Load Level: 1500

# Heavy
Name: batch
Load Level: 5000

# Database
Name: dbupdate
Load Level: 3000

Usage:

bash

# Submit jobs with appropriate interpreter
btr -i reports daily-sales.sh       # Load: 500
btr -i process data-transform.sh    # Load: 1500
btr -i batch warehouse-load.sh      # Load: 5000
btr -i dbupdate customer-sync.sh    # Load: 3000

Scenario:

LOADLEVEL: 20000
Current running jobs:
  2 × warehouse-load (5000 each) = 10000
  4 × data-transform (1500 each) = 6000
  CLOAD: 16000

Can still run:
  8 × reports (500 each) = 4000 (total 20000)
  Or 2 × data-transform (1500 each) = 3000 (total 19000)
  Or 1 × dbupdate (3000) = 3000 (total 19000)
  
Cannot run:
  warehouse-load (5000): Would exceed (16000 + 5000 > 20000)

Managing Total Workload

Running fewer jobs during business hours:

bash

# Morning: reduce LOADLEVEL
btvar -s LOADLEVEL 5000

# Evening: increase LOADLEVEL
btvar -s LOADLEVEL 20000

Automate with jobs:

bash

#!/bin/bash
# reduce-load.sh (runs at 8 AM)
btvar -s LOADLEVEL 5000

bash

#!/bin/bash
# increase-load.sh (runs at 6 PM)
btvar -s LOADLEVEL 20000

Schedule:

bash

btr -t "08:00" -r Days:1 reduce-load.sh
btr -t "18:00" -r Days:1 increase-load.sh

Mixing Production and Admin Jobs

Use load level ranges to separate job types:

Strategy:

Production jobs: 100, 200, 300, ... (multiples of 100)
Admin jobs: 1, 2, 3, ... (units)

LOADLEVEL: 20010
  Allows: 20000 units of production
          + 10 units of admin

Example:

bash

# Production jobs use 100+ load
btr -i production -l 100 prod1.sh
btr -i production -l 200 prod2.sh

# Admin jobs use 1 load
btr -i admin -l 1 cleanup.sh
btr -i admin -l 1 monitor.sh

Result:

Up to 200 small production jobs (100 each) can run, AND up to 10 admin jobs (1 each) can run simultaneously.

Graceful Shutdown

Stop Xi-Batch allowing jobs to complete:

bash

# 1. Set LOADLEVEL to 0 (no new jobs)
btvar -s LOADLEVEL 0

# 2. Wait for CLOAD to reach 0
while [ "$(btvar -v CLOAD | awk '{print $2}')" != "0" ]; do
    echo "Waiting for jobs to complete..."
    sleep 10
done

# 3. Stop scheduler
btquit -y

Scripted graceful shutdown:

bash

#!/bin/bash
# graceful-shutdown.sh

echo "Setting LOADLEVEL to 0..."
btvar -s LOADLEVEL 0

echo "Waiting for running jobs to complete..."
while [ "$(btvar -v CLOAD | awk '{print $2}')" != "0" ]; do
    CLOAD=$(btvar -v CLOAD | awk '{print $2}')
    RUNNING=$(btjlist | grep " Run " | wc -l)
    echo "  Current load: $CLOAD, Running jobs: $RUNNING"
    sleep 10
done

echo "All jobs complete. Stopping scheduler..."
btquit -y
echo "Xi-Batch stopped."

Starting Admin Tasks When Batch Complete

Use CLOAD condition to trigger admin work:

bash

# Admin job waits for no production jobs
btr -c "CLOAD = 0" \
    -A "backup_status = Running @ Job start" \
    -A "backup_status = Complete @ Job completed" \
    nightly-backup.sh

Or wait for load below threshold:

bash

# Run when load drops below 100
btr -c "CLOAD <= 100" \
    database-maintenance.sh

Load Level Best Practices

Assign meaningful load values:

Base on actual resource usage:

  • CPU-intensive: Higher load
  • I/O-intensive: Moderate load
  • Network-intensive: Moderate load
  • Quick scripts: Low load

Use round numbers:

  • 100, 500, 1000, 1500, 2000, 5000
  • Makes calculations easier

Leave headroom:

Don't set LOADLEVEL to exact system capacity. Leave margin:

bash

# System can handle ~100 medium jobs
# Set LOADLEVEL to 80% of maximum
LOADLEVEL=80000  # Instead of 100000

Monitor usage:

bash

# Watch load levels
watch -n 5 'btvar -v LOADLEVEL CLOAD; echo ""; btjlist | grep " Run "'

Document load classifications:

Maintain list of job types and their load levels:

Reports: 500
Data processing: 1500  
Database updates: 3000
Large batch: 5000
Warehouse load: 10000

Adjust based on observation:

Profile actual resource usage and adjust load levels accordingly.

Use command interpreters for enforcement:

Create interpreters with appropriate load levels, restrict special create privilege.

Don't micro-manage:

Having 100 different load levels is too complex. Use 5-10 standard values.

Setting Up and Managing Command Interpreters
Configuring shells and custom programs to run batch jobs