Hypothetical scenario. Northwind teams submit document conversions and scheduled reports. Dev places a queue in front of containers. Maya asks for a stable receipt even when dispatch is interrupted; Priya asks which data and services a running job may access.
Dev: “The queue can distribute the attempts.”
Maya: “Which durable fact makes the platform responsible for finishing this particular job?”
Connect submission identity, accepted lifecycle, admission, isolation and results. Start with approved job types and immutable inputs; arbitrary customer code remains a different security product. This is a core System Design case with no model or agent prerequisite.
Which durable fact makes this job accepted?
A submission contract identifies the tenant, job type, immutable input reference, selected limits and caller intention. Repeating an uncertain submission with the same intention returns the existing job identity. Reusing that identity with incompatible input is rejected. This prevents a lost receipt from silently creating another report or conversion.
The authoritative job record is durable before the service acknowledges acceptance. Record a recoverable scheduling obligation in the same transactional boundary where possible. A queue message can then be published and retried independently. Without that connection, a crash can leave an accepted job permanently absent from the worker queue.
Acceptance is not a reservation of immediate compute. The receipt states whether the job is admitted to a bounded queue and how its deadline and cancellation work. Reject before acceptance when the tenant’s retained-work or resource budget is exhausted. Returning an optimistic receipt and later forgetting the job violates the very contract the platform exists to provide.
Separate a logical job from each attempt
The scheduler assigns an attempt identity and ownership generation through a conditional transition. A worker claims that attempt, obtains narrowly scoped input access and runs the approved job type. Heartbeats are observations supporting timeout decisions; they do not prove that a silent worker has stopped.
Store attempt outcomes separately from the logical job state. A failed attempt may leave the job eligible for retry, while a terminal input error may end it. The final result reference is published only by a currently authorized transition. Logs and progress events help diagnosis but are not the sole source of accepted completion.
Use immutable result objects named by job and attempt. The platform can retain an unaccepted attempt’s object temporarily without exposing it as the authoritative result. A conditional result pointer connects the accepted job outcome to exactly one complete artifact. This avoids using overwrite arrival order as the winner rule.
Trace durable submission into a bounded worker capability
Hypothetical scenario. Submit operation K creates job J with immutable input and a durable scheduling obligation. A broker notification wakes the scheduler but is not the sole record that J exists. Scheduler restart rebuilds pending work from durable state rather than assuming every accepted job still has a queue message.
| Record | Fields | Authority |
|---|---|---|
| Job J | K, tenant, input digest, desired state | Submission owner |
| Attempt A | J, generation, worker, lease | Scheduler / job state |
| Resource claim | worker, CPU/memory, generation | Admission authority |
| Result candidate | J, attempt, input digest, object | Conditional result acceptance |
The scheduler chooses a worker compatible with the job's declared CPU, memory and capability requirements. A task queue distributes items; resource scheduling additionally decides whether a particular worker can admit the item without violating tenant or machine limits. Keep resource claims recoverable and release them through a guarded lifecycle.
A worker receives a scoped attempt identity, input reference and authority token, not unrestricted platform credentials. It uploads an immutable candidate result; the job authority accepts it only for the current attempt generation and required input. Cancellation changes which transitions remain legal, but a running process may continue until enforcement reaches it. State which effects can be stopped and which require protected remote identities.
Estimate useful capacity in worker time
Hypothetical worked example. Select twelve worker slots and a mean attempt occupancy of thirty seconds for one homogeneous job class. Ignoring scheduling overhead and failures, the attempt capacity is 12 ÷ 30 = 0.4 attempts per second, or 0.4 × 60 = 24 attempts per minute. This is a planning subtotal, not a measured service guarantee.
Select eighteen new logical jobs per minute and one attempt per job initially. Useful spare capacity is 24 − 18 = 6 jobs per minute. A backlog of one hundred twenty jobs would drain in 120 ÷ 6 = 20 minutes if arrivals and successful service remain constant. Increasing submission throughput does not increase those worker slots.
Now select an average of 1.2 attempts per successful logical job under retries. The same twenty-four attempts per minute support 24 ÷ 1.2 = 20 successful jobs per minute. Spare useful capacity becomes 20 − 18 = 2 jobs per minute, and the backlog drain estimate becomes 120 ÷ 2 = 60 minutes. Attempt occupancy and retry mix can differ in reality; these deliberately fixed assumptions expose the unit change.
Resource limits need an actual trust boundary
For the approved-type baseline, workers receive read access to declared inputs and write access only to their attempt output prefix. The control plane keeps scheduler credentials and tenant policy outside that environment. Apply CPU, memory, storage, network and wall-clock bounds; a memory cap does not bound outbound requests or retained logs.
Containers are a packaging and resource-management mechanism. Their suitability as isolation depends on the threat model, runtime and host boundary. Running hostile code may require a stronger sandbox and a separate worker fleet. Do not infer safety from a container icon while mounting broad credentials or permitting privileged host access.
Admission must also account for fairness. A tenant with a large backlog should not consume every scarce slot indefinitely. Separate classes or weighted scheduling can help, but enforce both retained-work limits and active-resource limits. Otherwise a polite active limit can coexist with an unbounded tenant queue.
In the wild: a Job controller retries execution
Kubernetes documents Job completion and replacement behavior. Inspect its failure and retry semantics before using it as the execution substrate. Controller-managed completion does not establish exactly-once business effects; the application still needs stable identities and a guarded result boundary.
The platform can translate an accepted job into a Kubernetes Job while retaining its own tenant, input and result contract. Avoid exposing raw infrastructure state as the complete user lifecycle. A pod may disappear while the durable job remains unresolved, and a completed process can still fail result publication.
A receipt survives but its message does not
Hypothetical failure scenario. The submission service writes a job record, acknowledges the caller, then crashes before sending its queue message. A dashboard reports the job as queued forever. The worker pool is idle because no worker knows the accepted obligation exists.
Recover from a durable scheduling obligation and reconcile accepted jobs that lack progress. Publishing twice is tolerable when delivery and attempt claims are idempotent. Publishing zero times indefinitely is not. Reconciliation needs a bounded scan and explicit age thresholds, not an operator’s memory of which receipts looked suspicious.
Choose the smallest platform that preserves the contract
A shared platform is useful when several teams need the same admission, isolation and lifecycle guarantees. For a single trusted report, an existing scheduler with durable state may be enough. The extra platform boundary is justified by common obligations, not by an assumption that every background task needs a custom control plane.
Measure accepted jobs, waiting age by class, attempt occupancy, useful completions, unresolved outcomes and artifact publication failures. Avoid reporting queue depth alone as health: a small queue can coexist with a stuck tenant, while a planned batch can create a large healthy queue. The next page removes a worker at an ambiguous moment and asks which authority remains valid.
Challenge the proposed mechanism
The submit reply was sent but broker publication failed. How does the platform recover J?
Reveal the design reasoning
The committed job and dispatch obligation remain authoritative. Rebuild notifications from that state, preserving K and J. Do not ask the client to submit a new business intention or grant the replacement worker broader capability.
Decision and reconsideration: Use durable submission, explicit resource admission and conditional results. Separate task delivery from scheduling authority.
Check the design against changed conditions
The queue publish failed after a durable receipt. May the job be forgotten?
Reason through the consequence
No. Recover the scheduling obligation and reconcile accepted work. The receipt bound the platform to a lifecycle even though immediate execution was not promised.
Retries increase to 1.2 attempts per successful job. Is spare capacity still six jobs per minute?
Reason through the consequence
Under the selected fixed occupancy, useful capacity becomes twenty jobs per minute, leaving two above eighteen arrivals. The backlog estimate increases to sixty minutes.
The process exited successfully but its artifact is incomplete. Is the logical job complete?
Reason through the consequence
No under the selected contract. Publish only a complete immutable artifact through the guarded result transition; process exit alone is insufficient evidence.
A durable baseline can still encounter a worker that disappears after producing output. Page 60 keeps the same job identity and capacity inputs while a replacement and the old process compete to complete the result.
Northwind decision log
Acknowledge a durable job and recoverable scheduling obligation.
Bound each attempt and publish results through current authority.
Next, recover worker loss without repeating uncontrolled effects.
Go deeper: Durable submission and bounded ownership
- Book chapter: Patterns of Distributed Systems: chapter 15: Idempotent Receiver — Unmesh Joshi. Use this resource to examine stable identities across uncertain submission replies.
- Book chapter: Patterns of Distributed Systems: chapter 26: Lease — Unmesh Joshi. Use this resource to examine time-bounded ownership without assuming process termination.
- Video lecture: From Smoothie Architecture to Layer Cake with Durable Execution — Sergey Bykov. Use this resource to examine durable scheduling separated from execution.
- Primary document: Kubernetes Jobs — Kubernetes project. Use this resource to examine controller completion and retry semantics.