Operating Image Generation at Scale: Queues, Retries, and Cost Boundaries
A practical design for image-generation queues, bounded retries, uncertain provider outcomes, and spending controls that survive worker failures.
Read articleHow to design an observable, fallback-ready, progressively deployable routing layer when one model is no longer enough.
Many teams start AI integration by hardcoding a model name in application code. That is fast enough for validation, but production changes the equation:
At that point you do not just need “another model.” You need a controlled routing layer.
In production, AI routing needs to answer four questions:
A practical minimum usually includes:
Do not overbuild weighted traffic splits on day one. A routing system that can switch safely is more valuable than one that only looks clever.
Many teams treat fallback as simply sending the same request again. That is retry, not fallback.
A real fallback changes at least one of these:
For example:
gpt-4oclaude-sonnet on timeoutgpt-4o-mini if a cheaper, steadier model is acceptableThe point is to keep delivery alive under budget, not to force users to absorb every provider failure.
Not every failure should trigger a model switch.
At minimum, separate:
Without failure classification, fallback becomes random hopping.
If switching happens but nobody can see it, the system will eventually drift out of control.
At minimum, log:
These fields answer two critical questions:
When introducing a new model, do not move all traffic at once.
A safer rollout looks like this:
It is slower, but it avoids the worst-case scenario: a fresh model taking down the main path on day one.
Routing layers do not exist to look advanced. They exist to preserve delivery under real instability.
If you can only afford three pieces of work, prioritize:
That foundation is enough to carry real production value. Weighted routing, quality scoring, and dynamic budget controls can come later.