Fave retweeted
eu acho que essa foi a primeira propaganda contra o suicídio que eu achei bonitinha na vida
Yesterday, I shared this inference engineering system design question.
Here is my solution. 🧵👇🏿
I am preparing for inference engineering interview as I work on my mini inference engine project.
To practice I asked Claude to create a realistic system design question, this is what I got -
Design an inference API that serves LLM completions to thousands of concurrent users, where some requests are latency-sensitive (chat) and others are throughput-sensitive (batch jobs).
I will share my solution tomorrow.
1
5
831
When a request comes in through the API gateway, it is tagged with a priority level based on the API key. This is more reliable than trusting a client-side flag. The request is then placed into a single priority-aware queue with an aging mechanism, so lower-priority batch requests never starve, even under continuous chat traffic.
For serving, I use continuous batching. As requests finish, they leave the batch and new ones take their place immediately. No request waits behind a slower one. To support this at scale, I use paged KV cache. Instead of reserving the maximum memory up front, each request claims additional memory pages only when it needs them. This allows more concurrent requests to fit into the same GPU memory.
Tokens are streamed back to the client with Server-Sent Events (SSE). The server only needs to push tokens to the client, so SSE is a good fit.
For horizontal scaling, I run multiple GPU replicas behind a load balancer. Instead of round robin, I route each request to the replica with the lowest GPU memory usage. GPU replicas keep in-flight KV cache state, so load-aware routing is a better choice.
For observability, I would track Time to First Token (TTFT), tokens per second, queue depth, and GPU memory utilization with Prometheus and Grafana. These metrics help detect performance problems before they affect users.
In short, scheduling provides fairness between chat and batch traffic, paged KV cache improves memory efficiency, and load-aware routing improves horizontal scaling.
What would you change in this design?
88
I am preparing for inference engineering interview as I work on my mini inference engine project.
To practice I asked Claude to create a realistic system design question, this is what I got -
Design an inference API that serves LLM completions to thousands of concurrent users, where some requests are latency-sensitive (chat) and others are throughput-sensitive (batch jobs).
I will share my solution tomorrow.
Build it without Redis first.
You'll understand exactly what Redis solves — and exactly when you need it.
Full code on GitHub: github.com/0xfave/job-queue
13









