Retry, checkpoint and cost limits
Retry only recoverable failures
Retries restart failed attempts, not the application state. AWS Batch retry strategy counts the initial run as an attempt; evaluateOnExit can classify failures for RETRY or EXIT. A job terminated by its Batch attempt timeout is not retried automatically by Batch; a job that fails before timeout may retry under its policy. Spot interruption or transient dependencies can justify bounded retries; malformed input should fail permanently. A checkpoint records completed progress durably, associated with the input version. Save a complete checkpoint before replacing the previous one; resume only from a matching valid checkpoint.
Bound the work before submitting
The local fixture below uses 12 jobs, 2 vCPUs and 3 GiB per job, 8 vCPUs and 16 GiB pooled capacity, ten minutes per attempt and at most two attempts. Four slots are available. At an invented 0.06 USD per job-hour, 24 ten-minute attempts cost 0.24 USD for modeled compute. This excludes idle hosts, startup, storage, requests, network, logs and other charges. It is not a real AWS quote or a guaranteed bill ceiling. A per-attempt timeout is not an end-to-end deadline. Limit queue size, concurrent work, total submissions and retries; budget alerts are not immediate kill switches.
{ "jobs": 12, "poolVcpu": 8, "poolMemoryGiB": 16, "jobVcpu": 2, "jobMemoryGiB": 3, "attemptMinutes": 10, "maxAttempts": 2, "hypotheticalUsdPerJobHour": "0.06", "maxPending": 8}Apply backpressure and protect outputs
If workers consume four inputs per ten minutes but producers submit ten, the backlog grows by six each interval. Pause or slow producers at a queue threshold and resume below a lower threshold to avoid rapid switching. Use a stable output key derived from input identity and processing version; publish a validated result once through a conditional write or a transaction. Repeated attempts must not double-charge a customer or append duplicate rows. Store checkpoints with restricted access, monitor age and error counts, and investigate stalled capacity before submitting replacements.
Offline practice and cleanup
Run python test_batch.py from lab-fixtures/batch-scheduling with Python 3. Predict slot count, dependency eligibility, retry decision, checkpoint validity and modeled compute budget before running. The tests use small in-memory inputs; no workers, cloud resources, network, or benchmark are launched. Inspect the failed-input and timeout cases. A real design would also need verified service quotas, region-specific pricing, IAM, log retention, termination and cancellation controls. No paid cluster or GPU lab is authorized.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Retry, checkpoint and cost limits — knowledge check
Reason about finite workloads and bounded scheduling using synthetic scenarios.
A Batch attempt exceeds its configured timeout and Batch terminates it. What happens?
A two-attempt policy means what?
A checkpoint belongs to a different input revision. What should the worker do?
Four items finish and ten arrive each interval. How does backlog change?
What does the hypothetical 0.24 USD estimate include?