Scheduling and Workload Balancing

Modified on Mon, 30 Nov at 12:53 PM

Utility jobs compete with everything else on the system. They need a window, free space, objects that no one is holding and a place in the batch flow, and a REORG that starts at the wrong moment fails, or blocks the application it was meant to help. In most shops the answer is a fixed schedule, tuned by the DBA team over the years, that runs the same jobs at the same time whether the moment is right or not. TUC replaces it with a single queue of utility requests that are scheduled, balanced and watched automatically, so the work runs when it can succeed, spread across parallel jobs that finish together, and in step with the applications around it.

Key Benefits

Separate Roles — Applications, existing jobs taken over by TUC and the policy ask for the work; the DBA team decides how it runs, without being part of every batch flow.

Your Scheduler — Jobs are handed to IBM Workload Scheduler, Control-M, ESP Workload Automation, Zeke or the Db2 administrative scheduler, or submitted directly, with their dependencies.

The Batch Flow Respected — Work follows the dependencies of the job that asked for it, and avoids the jobs planned for the same databases.

Safe Concurrency — The number of concurrent jobs is governed, space is checked and reserved, and work on held objects is postponed until they are free.

Balanced Parallel Jobs — Where a profile runs in parallel, each request is split into jobs of about the same size, and one final job does the work that must be done once.

Nothing Goes Unnoticed — Every request is tracked from placement to completion; failed, cancelled and abended jobs are detected, and requests that need attention are sent by mail.

Why Scheduling Utilities Is Hard

A fixed utility schedule is a compromise. It must leave room for the worst night, so it is either too generous and wastes the window, or too tight and fails when the data grows. It cannot know that tonight an application is still holding the tablespace, that the storage group is short of space because three large REORGs are running at once, or that one of the parallel jobs received all the large objects and will run for hours after the others have finished.

Applications make it harder. A REORG after a large load, or a copy before a critical update, belongs in the application's batch flow, at the point where the application needs it. When the utility is built into the application jobs, the DBA team becomes part of every application schedule, and every change to the flow becomes a change to the utility jobs.


Separating the Roles

TUC separates asking for work from processing it. All utility work flows through orders: requests that say which utility to run on which objects. Anyone with the authority can place one:

  • The application asks. An application job places an order at the point in its flow where it needs the utility, and can wait for it to complete, so the next step starts only when the work is done.
  • The policy asks. The policy places orders for the objects that really need maintenance, according to their statistics.
  • An existing job asks. When TUC takes over a legacy utility job, the job places an order for its objects instead of running the utility itself, without any change to its JCL, and can wait for the order and pass on its dependencies.
  • The DBA asks. An order can be placed directly for any profile or object, with a start time if needed.
  • The DBA team processes. How the work runs is decided in one place: the scheduler, the window, the number of parallel jobs, the concurrency and the space. None of it is written into the application jobs.

The application team keeps control of when its work is needed. The DBA team keeps control of how it is done. Neither has to change the other's jobs, and every order is recorded with the job that placed it.


Supported Schedulers

TUC hands its jobs to the scheduler the site already uses, together with their start times and dependencies:

  • IBM Workload Scheduler. Jobs are added to the current plan with their predecessors and successors.
  • Control-M. Jobs are added to the active jobs with their conditions and time limits.
  • ESP Workload Automation. Each order becomes an application with its jobs, their dependencies and their start and due-out times.
  • Zeke. Jobs are added as events with their schedule time and their dependencies on other jobs.
  • Db2 administrative scheduler. Jobs are added as tasks, which suits sites that want no external scheduler or an evaluation in one place.
  • Direct submission. Jobs can be submitted directly, or as JES2 job groups that keep the order of the jobs, with TUC governing the concurrency itself.

Sites that prefer a fixed schedule can keep one. TUC can fill a fixed set of scheduled jobs with the work that is needed each day, and the jobs that are not needed simply do nothing.


Following the Batch Flow

An order placed from an application job can inherit that job's scheduling dependencies. TUC reads the predecessors and successors of the job that placed the order and adds the same dependencies to the order's jobs, so the application's successors wait for the utility exactly as they would have waited for a step of their own.


Avoiding Jobs Planned for the Same Time

Orders placed by the policy have no batch flow of their own, yet they can still collide with one. With IBM Workload Scheduler, TUC protects them before they are scheduled. It first estimates how long the work will run, from the size of the order and the processing rate of earlier orders. It then looks in the current plan for the utility jobs that are known to process the same databases and are planned to start before that time is up. Each job it finds is added to the order as a predecessor, so the order starts only after those jobs have finished, and the two never compete for the same objects.

A dependency must not hold the work forever. When a job it waits for is late, has failed or is itself blocked, the dependency can be removed by the DBA, and for orders placed by the policy it is removed automatically once the order has waited too long.


Maintenance Windows

Many sites allow heavy maintenance only at certain times: REORG on Saturday night, copies every evening, statistics at the end of the month. TUC uses the autonomic maintenance windows that Db2 itself defines, so the windows are kept in one place, in the Db2 catalog, and are shared with Db2's own autonomic statistics maintenance.

A window is defined for a day of the week or a day of the month, with a start and an end time, and for one utility or for all of them. Each window can also limit how many orders it takes, so a future batch window is never booked beyond what it can process.

An order does not need to know when the next window is. Placed with an automatic start time, it is assigned to the next open window for its utility: its start time is set to the start of the window and its deadline to the end. A REORG ordered on Thursday for a window on Saturday between three and five in the morning is scheduled for three on Saturday, with a deadline of five. When a window already holds as many orders as it allows, the order moves on to the next window that has room. The application or the DBA simply asks for the work, and the window decides when it runs.


Controlling Concurrency and Space

TUC governs how much utility work runs at the same time:

  • Concurrent orders. The number of orders running together can be limited, so that a burst of requests, or a process triggered by mistake, never floods the system.
  • Precedence. Orders placed by applications are processed before orders placed by the policy, and orders that an application job is waiting for come first, so the batch flow is not delayed by routine maintenance.
  • Start times. An order can be given a start time, or placed in the next open maintenance window, as described above.
  • Fitting the window. The work the policy selects can be capped by number, by size or by time, and the size that fits a time limit is calculated from the processing rate of earlier orders.
  • One order per profile. When several orders are placed for the same objects, the later ones wait for the first to complete, and for a grace period if it fails, so it can be restarted first.

Space is checked before each REORG starts. TUC verifies that the storage groups for data and work can hold the shadow datasets and work files the REORG will need, and reserves that space for the order, so the next order is measured against what is left. When space is short, the order is postponed for a few minutes while the running REORGs complete and release their space, and the orders that still fit continue in the meantime.


Postponing Work on Held Objects

A utility that starts while an application is holding its objects either waits and times out or forces its way in. TUC checks first. When objects in the order are held by applications, and the utility would need to drain them, the order is postponed.

The holding job is recorded with the order, so anyone can see which job kept the work waiting, and the order's flow chart shows the blocking jobs beside the jobs it waited for. The order is postponed for a few minutes and then checked again, and it starts as soon as the objects are free. The check is so light that it can be repeated as often as needed, so the work does not depend on a forecast of when the application will finish. Batch jobs run late and rarely end at the same time twice; TUC follows what the application is really doing tonight, and the utility jobs settle into the gaps of the application flow without anyone tuning them.


Balancing the Workload

Not every profile needs parallel jobs, and not every utility should run in parallel. A small database runs as one job. A large one can be split into several parallel jobs, and parallel processing is switched on per utility: by default COPY and REORG run in parallel and RUNSTATS runs as a single job. Where a profile is split, its objects are distributed by size in a way that gives every job about the same amount of data, so the jobs finish at about the same time instead of one job running long after the others.

An order often covers only some of a profile's objects, for example the candidates the policy selected. TUC rebalances every order, redistributing its own objects between the parallel jobs, so that the jobs are even for the work actually requested. The distribution respects how each utility works: partitions can be copied independently, but partitions that a REORG must process together, or that statistics must aggregate, stay in the same job. When the work is too small to split usefully, it runs as a single job.


One Final Job for the Whole Profile

Some work must be done once, for all the objects together, and never inside the parallel jobs. A parallel flow therefore ends with a synchronizing job, which starts only when every parallel job has completed successfully. It does what belongs to the profile as a whole:

  • A common point of consistency. A QUIESCE of all the objects in one statement gives a single recovery point after parallel copies, which separate QUIESCEs in each job could not.
  • Rebinding once. The packages that depend on the objects are rebound once, after all the REORGs, instead of by every parallel job. Parallel jobs would rebind the same packages several times, compete for them, and rebind some before all their tables were reorganized.
  • Completing the order. The synchronizing job marks the order completed and releases the application successors, so the batch flow continues only when all the work is done.

TUC moves these tasks to the synchronizing job automatically: an option such as rebinding is switched off in the parallel jobs and carried out once at the end.


Mixing Large and Small Work

When the policy places many REORG orders, TUC also decides their order. Within each priority, the orders are grouped into small, medium and large work, and the groups are interleaved instead of running all the large ones together. Several large REORGs at once can exhaust the space for their shadow datasets; mixing them with small ones keeps space turning over and the storage groups evenly used.


Tracking Every Order

Every order moves through clear states: pending, scheduled, executing, completed or failed, with held, postponed and cancelled along the way. The status of each order, its objects, its jobs and their results can be seen at any time, and each order shows the job that placed it, the jobs that held its objects, the jobs it waited for and the jobs that followed.

TUC also checks on the jobs while they run. When a job of an executing order was cancelled, abended or failed on a JCL error, the order is marked failed at once, instead of appearing to run forever. A failed order can be restarted, and an application job that is waiting for it reports the failing job, the step and the return code, and can be restarted itself to resume waiting without any change.

Orders that need attention do not wait for someone to look. When an order is held and waits for a decision, TUC sends a mail with the order, its objects and its status, and writes a console message, so outstanding work is dealt with before it delays the batch.


Light Enough to Check Every Few Seconds

All of this is driven by one processing task that checks for new orders at a set interval. Between checks it uses no resources. Because each check is so light, the interval can be as short as a few seconds, and an order placed by an application is picked up almost at once. The task can run as a started task or a long-running job, its options can be changed while it runs, and it can be shut down cleanly each day.


Without and With TUC

Task Without TUC With TUC
Utility work in the batch flowBuilt into each application job by the DBA team.Ordered by the application; processed by TUC.
SchedulingA fixed schedule, tuned over the years.Orders handed to the site's scheduler with their dependencies.
Maintenance windowsEach job given a fixed place in a window.Orders assigned to the next window with room, up to its limit.
Collisions with application jobsAvoided by experience.Planned jobs found and waited for automatically.
Held objectsThe utility times out or forces its way in.The order is postponed and checked again until the objects are free, and the holding job is recorded.
Space for concurrent REORGsFailures when the storage group fills up.Space checked and reserved; orders postponed until it is free.
Parallel jobsFixed splits that drift out of balance.Every order rebalanced by size; large and small work mixed.
Work for the whole profileRepeated in every parallel job, or forgotten.Done once by the synchronizing job: one QUIESCE, one rebind.
Failed and cancelled jobsFound when someone looks.Detected at once; held orders reported by mail.

In short — TUC turns utility scheduling into a managed queue. Applications, existing utility jobs taken over by TUC and the policy ask for the work, and the DBA team decides how it runs. Orders go to the site's own scheduler and follow the batch flow, concurrency and space are governed, work on held objects is postponed until they are free, parallel work is balanced and closed by a single synchronizing job, and every job is tracked until it completes, with a processing task light enough to check every few seconds.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article