Sizing an upscaling worker by the uploaded file alone is a good way to end up with unexpected costs. The upload is just the input. The output is what determines how much work the render requires.

A routing rule that holds up in production:

  1. Calculate the output pixel count from the source dimensions and requested scale factor.
  2. Reject jobs that exceed your processing limit before they start, and explain the reason to the user.
  3. Select the processing engine based on the output size, then log that decision against the job ID.

A cheaper engine on a small source image can sometimes produce a better result than an expensive one. More reconstruction doesn't necessarily mean more accuracy, especially with logos and small text. Let users preview a crop before committing to a full render.

Provider failures need explicit handling too. If an upstream job fails, refund the reserved credits instead of leaving the user wondering what happened to their balance. Make refunds idempotent: retrying the failure handler should never return the same credits twice. It's a small implementation detail that can prevent a lot of support tickets.

On Quixary, routing is based on output pixel count, and the credit cost is shown before the render starts. The same principle applies to any system where processing costs depend more on the final render than on the uploaded file.