Think Build Implement Repeat
London, UK +44 7367 067226
WhatsApp FOLLOW f in X
  1. Home
  2. Blog
  3. Setting a Latency Budget for Real-Time Predictions
AI & Machine Learning

Setting a Latency Budget for Real-Time Predictions

Real-time costs far more than batch, and much of what is specified as real-time is not. How to work out the genuine requirement before building for it.

Updated 2 min readBy SpiderHunts Technologies

Free estimateNo obligation

Get a free estimate

Tell us what you need. A senior engineer reads every enquiry.

Takes under a minute. We never share your details.

  • Free consultation
  • No commitment
  • NDA on request

Prefer to talk? Book a free 30-minute call →

Quick answer — TL;DR

Most of a prediction's latency is spent fetching features, not running the model. Work backwards from what the user or process actually experiences, and check whether the decision could be precomputed - a large share of real-time requirements dissolve on inspection.

Real-time is a cost decision

Serving predictions on demand within a page load is substantially more expensive to build and run than computing them overnight. It needs an always-available service, low-latency access to features, monitoring and an answer for what happens when it is slow.

So it is worth asking, before committing, whether the requirement is real. A surprising share of 'real-time' specifications turn out to mean 'reasonably current', which a scheduled refresh satisfies at a fraction of the cost.

Work backwards from the experience

Where the prediction appearsRealistic budgetImplication
Inside a page renderTens of millisecondsGenuine real-time; feature access is the constraint
After a user action, with a spinnerA few hundred millisecondsReal-time, more forgiving
In a back-office queueSecondsNear-real-time; simpler architecture
On a report or dashboardMinutes to hoursBatch is fine
Driving a daily processOvernightBatch, and far cheaper

Placing the requirement honestly in this table is usually a five-minute conversation that saves a great deal of engineering.

The model is rarely the slow part

For most business models, inference itself takes a few milliseconds. The time goes on everything around it.

  • Fetching features from several systems, sometimes sequentially
  • Computing aggregates on the fly - 'orders in the last 90 days' over a large table
  • Network hops between services
  • Cold starts where the service scales from zero
  • Serialisation, authentication and logging

This is why feature access dominates the design. Precomputing aggregates and storing them ready to read converts the expensive part into a lookup, and is usually the single biggest latency improvement available.

Precomputing more than you expect

Where the set of things you might be asked about is bounded - your customers, your products, your sites - you can compute predictions in advance and serve them from a table.

This gives real-time response times with batch economics. It fails only where the prediction depends on something known just before the request, such as the contents of the current basket, and even then a hybrid works: a precomputed base score adjusted by a small live component.

Specify the tail, not the average

Average latency hides the problem. If the average is 40 milliseconds and the slowest one per cent takes four seconds, those slow requests are concentrated in exactly the sessions you care about - complex accounts with more data.

Set the target on a high percentile and monitor it there. And decide in advance what happens when the budget is exceeded: serve a default, skip the personalisation, or make the user wait. That decision belongs in the design, not in an incident.

Most real-time requirements are a habit. Ask what actually breaks if the number is an hour old.

FAQ

Frequently asked questions

The questions readers ask us after this guide.

Still have a question?

Ask us directly — a senior engineer will get back to you.

Ask about your project

Is batch always cheaper?

Usually considerably, because there is no always-on service and computation is amortised. The trade is freshness.

How do I know if my latency is a problem?

Measure at a high percentile under realistic load rather than averaging in development. The tail is where users notice.

Can we start batch and move to real-time later?

Yes, and it is often the sensible order. Batch proves the model's value cheaply before you invest in the serving infrastructure.

What should happen when the model is slow?

Decide in advance - a default response, a cached value, or degrade gracefully. Never leave it undefined.

Keep reading

More on AI & Machine Learning

Start here

Want machine learning project details from us?

Tell us what you are trying to predict and roughly what data you hold. We will come back with an honest view on whether machine learning is the right tool, what the work would involve and a realistic cost range. If a spreadsheet would do the job, we will say so.

  1. You tell us what you needTwo minutes on the form, or a message on WhatsApp.
  2. A senior engineer reviews itAnd comes back with questions, a realistic range and an honest view on fit.
  3. Free 30-minute scoping callWe talk through scope, options and a realistic estimate — with no obligation.
Free estimateNo obligation

Talk to someone who builds this

Send a short brief and we will come back with an honest view and a realistic range.

Takes under a minute. We never share your details.

  • Free consultation
  • No commitment
  • NDA on request

Prefer to talk? Book a free 30-minute call →