JINNFLUXResearch & insights

Set the Decision Deadline Before the Microbatch Size

Set microbatch flush times from consumer deadlines, account for padding and inference cost overruns, and measure useful throughput across arrivals and bursts.

A checkout score loses its value when the authorization handler makes its decision. Set the batch timer from the remaining time to that decision. While an executor is busy, a compatible request can join an open batch without delaying its start. The extra request can still push the whole batch into a more expensive padded shape and turn a feasible submission into a miss.

Consider a fictional fraud scorer that handles live checkout authorizations and relaxed-deadline review work. A retried authorization creates a new attempt ID, so a result for the original attempt may reach checkout before the retry's cutoff and still belong to the wrong decision. Carry the attempt ID and deadline through dispatch. The consumer accepts a score only if it matches the current attempt and arrives by its cutoff. The first attempt placed in a batch is its opener. All scenario timings, traffic rates, budgets, and thresholds below are illustrative.

The opener's latency bill

A live authorization has 200 ms from event creation to a usable score at checkout. Allocate 40 ms to source and transport, 60 ms to admission and batch formation combined, 80 ms to inference, and 20 ms to postprocessing and delivery. To derive a conservative 1% bound on end-to-end timing overruns from those four time caps, allow each segment to exceed its cap on at most 0.25% of strict attempts, equivalent to checking each cap at p99.75. If the complete path is covered and every cap holds, their sum stays within 200 ms. The union bound allows the segment overruns to be correlated. Measure usable scores at checkout directly, since an attempt can also fail through a drop or an invalid result.

After 50 ms in admission, an authorization has 10 ms left in its combined waiting allowance. A full 20 ms formation wait would overrun that allowance. Convert the upstream cutoff into a local monotonic deadline using a clock uncertainty guard. For example, hosts each within 2 ms of a shared reference can disagree by up to 4 ms. Deduct that guard when translating the remote cutoff into remaining time, then measure subsequent waits on the local monotonic clock. The guard advances the scheduler cutoff without changing the consumer's deadline.

Figure 1 follows three openers under a fixed-timer policy. Each spends 40 ms in source and transport and 20 ms in postprocessing and delivery. Admission takes 2 ms in quiet traffic, 8 ms at steady load, and 70 ms in the burst. The quiet batch flushes at the 20 ms timer. The steady and burst batches fill in 4 ms and 2 ms. The executor takes each batch as it closes and runs it for 55 ms, 70 ms, and 85 ms, respectively. The resulting paths take 137 ms, 142 ms, and 217 ms. A dashboard that starts its wait clock when the batch opens makes the burst look best even as checkout records a miss.

Figure 1 — Illustrative authorization paths, not measured data. The burst opener spends 72 ms across admission and formation against a combined allowance of 60 ms. Its 85 ms inference run adds another 5 ms beyond plan, putting delivery 17 ms past the 200 ms cutoff.

The latest safe submission time

Keep batch membership separate from the choice of which work reaches the executor first. Hot-key scheduling covers how a shared lane divides service among keys. Feature freshness covers whether a score can use the available inputs. Once a set of requests is eligible to run together, the microbatch scheduler owns the size and padded shape of the submission.

Within a compatible group, start with the earliest eligible deadline. Estimate inference time for the candidate's batch size and padded shape on the serving hardware. Adding a review item can move the entire batch into a higher padding bucket, increasing the cost for every member. Price the proposed batch as a whole each time membership changes.

slack = (earliest deadline − now) − executor backlog − predicted execution − delivery reserve

Executor backlog is the time until the batch can start, including any work already ahead of it. Slack measures how much later than that predicted start the batch can begin. When formation overlaps with backlog, the projected time until start is the greater of the planned remaining formation wait and the backlog, provided the scheduler can still use that executor slot. A shared executor can assign the slot elsewhere while the batch waits. Use a slot the dispatcher can reserve or account for competing dispatches in the start estimate. Set the wake-up to the earlier of the 20 ms formation ceiling and the latest feasible start. Recompute feasibility on arrivals, executor state changes, and before submission. If adding a peer makes the larger batch infeasible, keep the feasible subset and submit when the executor can take it. If even a singleton cannot meet its guarded deadline, return control to checkout for its timeout path and count the attempt as a miss.

At the instant a batch opens, suppose its opener has 95 ms left on its guarded clock and the executor will be free in 12 ms. The model predicts 55 ms for the current batch. With 20 ms reserved for postprocessing and delivery, starting at executor availability uses 87 ms and leaves 8 ms of slack. A prospective peer with a later deadline raises predicted inference to 57 ms. At executor availability, the larger batch would use 89 ms and leave 6 ms of slack, so it must start by 18 ms from opening. If the scheduler holds the batch for a peer that arrives at the 20 ms timer and immediately submits, delivery at 97 ms exceeds the guarded cutoff by 2 ms even with a correct cost estimate. The executor idles for 8 ms after clearing its backlog. A scheduler that reserves time for the larger shape stops waiting by 18 ms at the latest and can launch the smaller batch then if the peer has yet to arrive.

Cost error can sink even the earliest submission. Suppose the 55 ms prediction comes from the correct padded-shape bucket and contention during the run stretches execution to 68 ms. Starting at 12 ms now puts delivery at 100 ms, 5 ms past the guarded cutoff. A recheck using the same 55 ms prediction catches a change in executor availability but leaves the execution forecast unchanged. Any execution margin greater than the 8 ms of remaining slack would rule out that batch before submission, even on a run that would have taken 55 ms. Set the margin before the replay from a high percentile of positive prediction errors in prior runs at the same batch size, padded shape, and contention level. Choose the percentile by measuring both strict misses and lost goodput on held-out traffic. Try a cheaper subset and reprice it before dispatch. Track shape-bucket transitions separately from within-bucket errors so a larger margin cannot conceal a bad cost lookup.

The throughput a consumer can use

Count valid, timely scores at the consumer and divide by all offered attempts to measure deadline success. Include attempts shed at admission or expired before dispatch. Keep the same numerator over elapsed time for goodput. Report both by class in experiments because aggregate gains can hide losses on the strict path.

Figure 2 uses a fictional replay offering each policy 1,250 attempts per second, split into 625 strict checkout and 625 review attempts. A uses a small fixed target, B uses a larger fixed target, and C uses deadline-aware formation. The policies share the same executor, priority rules, and offered trace. Count completions for the offered cohort after outstanding work finishes or expires, and express them per second of offered traffic so a score produced during drain cannot inflate the replay rate.

Policy Total completions per second Timely and valid per second, both classes Timely and valid per second, strict checkout
A 1,000 950 (76%) 550 (88%)
B 1,200 900 (72%) 500 (80%)
C 1,100 1,040 (83.2%) 600 (96%)

A and B each deliver 400 timely and valid review scores per second (64%). C delivers 440 (70.4%). B leads on completion count, yet C delivers 100 more timely checkout scores and 40 more timely review scores per second. C also delivers 50 more timely checkout scores per second than A under this workload. The 96% checkout result describes the fixed mix. The release test changes the load and applies a higher threshold to each burst cohort.

Figure 2 — Illustrative fixed-mix replay, not measured data. Each policy's two marks share its total completion rate. Diamonds use the 625 offered checkout attempts per second as the denominator. Circles use all 1,250. C leads on both success rates despite completing 100 fewer scores per second than B.

A burst with an explicit review limit

In a separate fictional release replay, compare the incumbent small fixed-target policy A with the deadline-aware candidate C. Start at 800 offered attempts per second, jump to 1,400 per second for ten seconds, then return to 800. Split offered traffic evenly between checkout and review. During the burst, admit all 700 strict attempts per second and cap review admission at 300 per second. Shed the other 400 review attempts per second at ingress and count them as review misses. Calibrate sustained capacity on the traffic admitted after shedding, 700 strict and 300 review attempts per second. Assume A and C can each sustain 1,000 completions per second for that mix on the release hardware. That capacity leaves no headroom to drain existing backlog while the step lasts. Give checkout priority at batch selection, and lift the review cap when offered load returns to baseline. A review batch already running at the start of the burst still holds its executor slot until it finishes.

Group strict attempts into one-second arrival cohorts aligned with the start and end of the step. Credit scores to the cohort that offered the attempt and finalize each cohort after all its deadlines have passed. Require C to achieve at least 98% strict success in every burst cohort and at least as many timely strict scores across the burst as A delivers. Measure recovery from the return to 800 until the start of the first of two consecutive post-burst cohorts with at least 99% strict success. Require that first cohort to start within two seconds of the return and observe the second before declaring recovery. Report review goodput and deadline success through drain. Strict recovery can precede review recovery when strict arrivals continue to take priority over review work admitted during the step.

Schedule the batch to start by the earliest guarded consumer cutoff minus the padded batch's execution estimate, uncertainty margin, and delivery reserve. Use the time before the executor becomes available to collect compatible work, and reprice the batch when a peer changes its shape. Promote a policy only when it meets the burst and recovery targets at checkout. Count the benefit of fuller batches in usable scores per second.