All Posts
AI Engineering July 28, 2026

Hybrid Local and Cloud Inference: Bursting Overflow from an M5 Max to a Cloud API Under Load (2026)

A single M5 Max is a genuinely good inference box for a steady stream of requests, and if your load were flat you would never need anything else. Real load is not flat. It has a baseline you can size hardware against and spikes you cannot, and the spike is where a local only setup fails: the queue depth climbs, time to first token blows past your latency budget, and users wait behind a machine that is already at full decode. The fix is not a bigger Mac, because you would be buying capacity for a peak that shows up a few hours a week and sitting idle the rest of the time. The fix is a hybrid: keep the baseline on local hardware where each token is nearly free and no data leaves your network, and burst only the overflow to a cloud API that you pay for by the token and only when you actually need it. The design problem is the router. A router that spills too early throws away the cost advantage you built the local tier for, and one that spills too late lets the queue hurt users before it reacts. This post covers how to set the spill threshold against queue depth rather than raw request rate, how to keep the cloud path from leaking data you meant to keep in house, what the blended cost actually looks like, and when a hybrid is worth its extra failure modes versus when one tier is the honest answer.

Hybrid Local and Cloud Inference: Bursting Overflow from an M5 Max to a Cloud API Under Load (2026)

An M5 Max serving local inference is cheap and private right up until the moment your traffic spikes, and then it is a queue. The machine keeps decoding at the same steady rate it always did, but requests now stack up behind the ones in flight, time to first token climbs, and the user who arrived during the spike waits for a box that is already busy. Buying a bigger Mac to survive the peak means paying for capacity that sits idle most of the week. The better answer is to keep your predictable baseline on local hardware and send only the overflow to a cloud API, paying per token exactly when demand exceeds what the local tier can absorb. Here is how to build that router, and the numbers that tell you whether it is worth the added complexity.

Why Baseline and Peak Are Different Problems

Inference load has two components that want different solutions. The baseline is the steady request rate your service sees most of the time, and it is predictable enough to size hardware against: if an M5 Max sustains your median load with headroom, that load costs you electricity and nothing else. The peak is the spike that arrives with a campaign, a cron job, a burst of concurrent users, or the front page of somewhere. It is short, it is hard to predict precisely, and it is the part that breaks a fixed capacity box.

Sizing a single local tier for the peak is the mistake most teams make first. If your baseline is ten concurrent requests and your peak is fifty, a machine provisioned for fifty runs at twenty percent utilization the rest of the time, which is a lot of unified memory and silicon sitting warm and idle. The economics of local inference come from high utilization of hardware you already bought, and over provisioning for a rare peak throws exactly that away. The cloud has the opposite shape: you pay per token with no idle cost, which is expensive at steady state but ideal for a spike you touch a few hours a week. A hybrid puts each kind of load on the tier built for it.

The Router Is the Whole Design

Everything hard about a hybrid lives in the decision of when to spill a request to the cloud. Get it right and you keep the local tier saturated and cheap while the cloud absorbs only true overflow. Get it wrong in either direction and the pattern loses its point.

The naive trigger is request rate: spill when requests per second cross a line. This is the wrong signal because it does not know how busy the local tier actually is. A high rate of short requests may be fine, and a low rate of long generations may already have the machine backed up. The signal that actually predicts user pain is queue depth, or more precisely the estimated wait before a newly arrived request would start generating. When that estimated wait exceeds your time to first token budget, the local tier is full and the next request should go to the cloud. This is the same admission control idea behind serving concurrent models in one memory pool, which we covered in the concurrent multi model serving writeup, applied at the boundary between two tiers instead of within one.

# Overflow router: spill to cloud only when the local queue would blow the SLA.
# Signal is estimated wait, not raw request rate.
TTFT_BUDGET_MS = 800          # the latency users tolerate before first token
LOCAL_SLOTS = 8               # concurrent generations the M5 Max sustains

def route(request, local_queue, avg_prefill_ms):
    est_wait_ms = (len(local_queue) / LOCAL_SLOTS) * avg_prefill_ms
    if est_wait_ms > TTFT_BUDGET_MS and request.allows_cloud:
        return "cloud"       # overflow: pay per token, only right now
    return "local"           # baseline: nearly free, stays in network

# request.allows_cloud is a per request flag. Data you must keep in house
# sets it False and waits for local rather than leaking to a third party.

The allows_cloud flag matters as much as the threshold. A hybrid quietly changes your data posture, because the whole reason many teams run local is that no request content leaves their network. The moment you spill to a cloud API, that request does leave. So the routing decision is not only about latency; it is about whether this particular request is allowed to go to a third party at all. Requests carrying regulated or sensitive data set the flag to false and wait for the local tier no matter how deep the queue is, and only cloud eligible traffic overflows.

Keeping the Cloud Path Honest

Two failure modes turn a clean hybrid into a mess, and both are worth designing against up front. The first is silent quality drift. Your local model and the cloud model are not the same model, so a request served locally and the same request spilled to the cloud can return meaningfully different answers, different formatting, different refusal behavior, different tool call shapes. If downstream code assumes one output contract, the overflow path becomes a source of intermittent bugs that only appear under load, which is the hardest kind to reproduce. The defense is to pin the cloud model to the closest available match, validate both paths against the same output schema, and treat any divergence as a contract violation rather than acceptable variance.

The second is cost runaway. The point of spilling only on queue pressure is that overflow is rare, but a misconfigured threshold, a stuck queue estimate, or a sustained real spike can send a large fraction of traffic to the cloud and quietly run up a bill that erases the reason you went local. Put a hard ceiling on cloud spend per window, expose the current spill rate as a first class metric, and decide in advance what happens when the ceiling is hit: shed load, degrade to a smaller local model, or accept the higher latency and keep everything local. A hybrid without a spend cap is a local setup with an uncapped cloud bill attached.

Concern Local only Cloud only Hybrid, done right
Steady state token cost Near zero Highest, every token billed Near zero for baseline
Behavior under spike Queue backs up, SLA breaks Absorbs it, you pay Baseline local, peak billed
Data leaving the network None All of it Only cloud eligible overflow
Failure mode to watch Undersized for peak Cost at steady state Spill rate and quality drift

What the Blended Cost Looks Like

The reason to build this is money, so make the money concrete. Take a workload with a baseline the M5 Max handles comfortably and a peak that runs a few hours a day at roughly five times baseline. Frame the numbers below as an illustrative model of that shape rather than a promise about your traffic, because the exact break even depends on how spiky your load really is and what your cloud provider charges per token.

Strategy Handles the peak Relative monthly cost Notes
Local only, sized for baseline No, queues during spikes Lowest, but breaks SLA at peak Users wait behind a full machine
Local only, sized for peak Yes Higher hardware, idle most of the week Paying for capacity you rarely use
Cloud only Yes Highest, every token billed always No idle cost, no data privacy
Hybrid, baseline local plus burst Yes Low, cloud billed only during spikes The overflow is the only cloud cost

The hybrid wins when your load is genuinely spiky, because you pay cloud rates only on the thin slice of traffic that exceeds local capacity while the fat baseline stays nearly free. It wins less, or not at all, when load is close to flat, because then there is no meaningful overflow and you have added a second tier and a router for a spike that rarely comes. The steeper your peak to baseline ratio, the more a hybrid earns its keep. This is the same total cost reasoning behind the decision to self host at all, which we lay out in the self hosting versus API cost analysis.

When One Tier Is the Honest Answer

A hybrid is not free, and there are shapes of load where a single tier is the right call. If your traffic is nearly flat, size the local tier for it and skip the cloud path, because the overflow you built the router for never arrives. If your traffic is almost all spike with little steady baseline, a local box mostly sits idle and cloud only is simpler and cheaper in practice. If every request carries data that legally cannot leave your network, there is no cloud eligible traffic to spill and the hybrid collapses back to local only with a router that never fires. And if your team cannot carry the operational weight of two inference paths, two sets of monitoring, and the quality validation between them, a single tier you run well beats a hybrid you run badly. The pattern earns its place when load is spiky, a real fraction of traffic is cloud eligible, and the peak to baseline ratio is steep enough that idle local capacity would cost more than occasional cloud tokens.

When This Applies to Your Stack

If you run local inference behind a product, plot your actual request rate and generation length over a representative week before you decide on an architecture. The shape of that curve, how high the peak sits above the baseline and how often it happens, is what determines whether a hybrid pays off or just adds moving parts. Set the spill trigger on estimated queue wait rather than raw request rate so it reacts to real pressure, mark which requests are allowed to leave the network and hold the rest on local no matter what, pin and schema validate the cloud model so overflow does not silently change your outputs, and cap cloud spend so a bad threshold cannot run up a bill. If your peaks are mild or your data is fully restricted, a single well sized tier is the honest answer, and a router that fires on the small fraction of eligible overflow is only worth it when the load is spiky enough to justify it. For a related pattern that keeps more work on the local tier by routing easy queries to a small model before escalating, see the local model cascade writeup.

If your team is putting local inference into a real backend and wants the router, the spill threshold, and the data boundary designed against your actual traffic rather than a benchmark, Contra Collective does AI infrastructure consulting that treats the local tier, the cloud path, and the routing policy as one system, so the baseline stays cheap and private and the spike still gets served.

FAQ

What does bursting to the cloud mean in local inference? It means running your steady inference load on local hardware, an M5 Max in this case, and sending only the requests that exceed local capacity to a cloud API. The local tier handles the predictable baseline at near zero per token cost, and the cloud absorbs short spikes you pay for only while they happen, so you avoid both queueing under load and paying cloud rates at steady state.

How should the router decide when to spill to the cloud? Trigger on estimated queue wait, not raw request rate. Request rate does not tell you how busy the local tier actually is, but the estimated time before a new request would start generating does. When that estimate exceeds your time to first token budget, the local tier is full and the next cloud eligible request should overflow. Requests carrying data that cannot leave the network stay local regardless of queue depth.

Does a hybrid setup leak data to the cloud? Only the requests you allow it to. A per request flag marks which traffic is cloud eligible; anything carrying sensitive or regulated data sets it to false and waits for the local tier even under load. The router must respect that flag before latency, so the privacy posture of your local setup holds for the requests that require it while non sensitive overflow uses the cloud.

Will the cloud model return different answers than my local model? Yes, unless you control for it. The two models differ in formatting, refusal behavior, and tool call shapes, so a request served locally versus spilled to the cloud can diverge. Pin the cloud model to the closest match, validate both paths against the same output schema, and treat divergence as a contract violation, because otherwise the overflow path becomes a source of load dependent bugs that are hard to reproduce.

When is a hybrid not worth building? When your load is nearly flat, size the local tier for it and skip the cloud path, since there is no real overflow. When load is almost all spike with little baseline, cloud only is simpler. When all traffic is data restricted, there is nothing eligible to spill. The hybrid pays off specifically when the load is spiky, a real fraction of it can go to the cloud, and the peak sits far enough above baseline that idle local capacity would cost more than occasional cloud tokens.

[ 02 ] — Keep Reading

More from the lab.

Oct 4, 2026 AI Engineering

The Model Context Protocol's STDIO Problem: Inside the Latest Remote Code Execution Disclosure

Security researchers at OX Security found that the Model Context Protocol's STDIO transport interface runs any process command passed to it on the host system before it ever confirms the subprocess is a valid MCP server, an execute first, validate never pattern that completes an injected command even when the caller eventually gets an error message back. The scope is not small: 150 million downloads across package registries, more than 7,000 publicly accessible MCP servers, and up to 200,000 vulnerable instances across every officially supported SDK, Python, TypeScript, Java, and Rust. Anthropic's response, after OX disclosed in January 2026, was to update documentation and call the behavior intentional. Here is what that actually means if your team runs MCP servers over STDIO.

Sep 30, 2026 AI Engineering

OpenAI's Decisions API: Real-Time Agentic Decision-Making for Enterprise Workflows, Explained

Buried inside OpenAI's DevDay 2026 announcement list alongside GPT-6.1 Sol and Dots agents was a smaller, more technically specific release: a Decisions API built for real time decision making against predefined answer sets. Where the Agents API and a general purpose agent loop are built for open ended reasoning across an unbounded task, the Decisions API is built for the opposite case, a small number of valid outcomes and a requirement that the choice happen fast. This post works through what that distinction actually means in practice and where a bounded decision primitive fits into an existing agentic workflow.

Aug 8, 2026 AI Engineering

Offline Batch Inference on an M5 Max: Maximizing Overnight Throughput for a Prompt Backlog (2026)

Most writing about local inference assumes a human is on the other end, watching tokens appear and judging the model by how fast the first one lands. Batch work is the opposite situation, and it is more common than the interactive framing suggests: you have a backlog of tens or hundreds of thousands of prompts, nobody is waiting on any single one, and the only thing that matters is how much of the pile you can clear before morning. Product descriptions for a catalog, classification over a support archive, embeddings and summaries for a corpus, synthetic data for a fine tune. In that regime latency is irrelevant and throughput is everything, and the settings that make a local server feel responsive to a person actively work against you, because they optimize for the wrong number. Running one prompt at a time on an M5 Max leaves most of the machine idle, since a single decode stream cannot saturate the memory bandwidth the chip has to offer. The job is to keep many sequences in flight so the expensive weight reads are amortized across all of them, and to arrange the backlog so the GPU never waits on padding, scheduling, or a slow tail. This post is about doing that deliberately: what actually bounds batch throughput on Apple Silicon, how far batching takes you before memory stops you, and the operational scaffolding that turns a fragile overnight run into one you can resume when it dies at 3am.

Ready when you are

Want to discuss this topic?

Start a Conversation