Skip to content
tezvyn:

CPU versus GPU serving: cost, latency, throughput

Source: interviewMediumHow cards are made

Summary

inference hardware tradeoffs.

Key points

GPUs win on throughput for batched parallel work but cost more; CPUs suit low-volume or small models.

Watch out for

claiming GPU is always faster or ignoring batching and utilization.

What's really being asked

This checks whether you can pick inference hardware based on workload economics rather than a reflex that GPUs are always better. It rewards understanding why GPUs help and when they are wasted.

The full answer

GPUs are built for massively parallel operations, so for large deep-learning models with heavy matrix multiplication they deliver far higher throughput than CPUs. That advantage is largest when you batch many requests together, because the GPU processes the batch in parallel and amortizes its overhead. The downsides are high cost per hour and poor utilization if traffic is low or requests arrive one at a time, since a GPU serving a single small input may sit mostly idle while you still pay for it. CPUs are cheaper, available everywhere, and well suited to small or classical models, low request volume, or strict single-request latency where batching is impossible. The right choice depends on model size and architecture, request volume and burstiness, whether you can batch, and your latency budget against your cost ceiling. Mention that GPU latency for a single tiny request can even exceed CPU latency due to data-transfer overhead.

The mistakes people make

Saying GPU is always faster and therefore always correct. Ignoring batching, which is what makes GPUs cost-effective. Forgetting that an underutilized GPU is expensive and that data transfer to the GPU adds latency for small payloads.

What usually comes next

How does dynamic batching change the calculus? When would you autoscale GPUs versus CPUs? What about quantizing the model to run on CPU?

A concrete example

A large image-classification model serving thousands of requests per second benefits from a GPU with dynamic batching, achieving high throughput at acceptable per-image cost. The same model behind an internal tool handling ten requests an hour is cheaper on a CPU, because a GPU would sit idle ninety-nine percent of the time while still billing every hour.

Interview question

For a large deep-learning model, what condition most makes a GPU cost-effective for serving compared to a CPU?

  • a.A single occasional request with a tiny input
  • b.A requirement to minimize hourly hardware cost above all
  • c.Running a small classical model like logistic regression
  • d.High request volume that can be batched to keep the GPU utilizedCorrect
Why?

GPUs pay off when batched high-volume traffic keeps their parallel units busy. Single tiny requests leave a GPU idle, strict cost minimization favors CPUs, and small classical models do not need GPU parallelism.

Just read this? Test yourself on what you have been reading.

Read the original → azure.microsoft.com

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on gpu — each one lists the topics its interview covers.

See open roles