Skip to main content

← ~/writing · November 3, 2026 · 1 min read

Serving a PyTorch model behind Next.js without a GPU

How a small CPU box handles our forecast traffic, and the three settings that mattered.

Our forecast model runs on a two-core CPU instance and answers in under 80 ms. Here is what made that possible.

Batch small, batch often

Micro-batching requests for 10 ms gave us four times the throughput with no visible latency cost.

Export once

TorchScript removed Python overhead from the hot path and halved cold-start time.

  • Pin threads to cores

  • Warm the model on boot

  • Cache by input hash

Share:

Keep reading