LLM Inference Service with Measured SLOs

Put a small language model behind a gateway that admits, budgets, routes and measures every request; load it until it breaks and read what the numbers say; set service level objectives and alert on how fast the error budget burns; decide with evidence whether a cheaper model file is good enough; and move traffic to it in steps you can undo. Everything runs on one Docker host with a CPU.

Inference Engineer. Advanced.

What you will build and explain

  • Explain TTFT, inter-token latency and throughput from the mechanics of prefill, decode and the KV cache, and predict which runtime setting changes which number.
  • Load a service honestly with an open-loop generator, read p50/p95/p99 and throughput, and check the measurement with Little's law before trusting it.
  • Set SLOs from a baseline, express them as Prometheus recording rules with buckets on the targets, alert on error-budget burn with two windows, and say what a firing alert means to handlers.
  • Protect a runtime with admission control and token budgets so that overload produces fast, explicit rejections with Retry-After instead of timeouts, and show the effect in a report.
  • Qualify a quantized model file with a calibrated evaluation gate on structured records, and state what the gate does and does not prove.
  • Canary a model file with weighted routing and measured checks from Prometheus, roll it back in one command, and compare both models on one dashboard.
  • Turn a rate sweep into a capacity statement and a cost per million tokens, and reason about what changes on a GPU or with a larger model.

Before you begin

  • Terminal, Git and Docker Compose basics; reading a Python function, JSON and YAML; no inference, Prometheus or load-testing experience is assumed, all of it is taught
  • A machine with 4 or more cores, 8 GB of memory for containers and 4 GB of free disk (Linux, macOS with Docker Desktop, or Windows with WSL 2), and about 1.5 GB of one-time downloads
  • No cloud account, GPU or paid API: the whole lab runs on your own machine

Who this is for

For engineers who write Python, use Docker Compose and HTTP APIs, and want to serve a language model within measured latency and cost targets: admission control, SLOs with burn-rate alerts, quantization evidence and canary rollouts.

Curriculum

Learning topics (16)
  1. Understand the brief and prepare one machine for the lab

    This project runs a language model on your own machine and surrounds it with the parts a serving team adds before anyone depends on it. Nothing leaves the machine, nothing costs money, and nothing is permanent, but the lab does hold a few gigabytes of memory and disk while it runs, and it is honest about what it assumes you know. This page covers four things: what you should already be able to do and what the project teaches; the machine, tools and downloads the lab needs; wh

  2. Follow a claim note through the serving system

    ClaimSense is small enough to hold in one picture and rich enough to show every decision an inference service has to make. This page follows a claim note from a handler's screen to the last streamed token, then follows a model-file change from the evaluation gate to a promoted canary, and finishes with what happens when things go wrong. Each section names the file that implements it; the lessons teach the concepts in depth and the file guides explain the code block by block.

  3. Tokens, prefill, decode and the KV cache

    Every number in this project, from the SLO targets to the cost per million tokens, follows from how a language model produces text. This lesson explains that process well enough to predict what the service will do before you measure it: why the first token takes longer when the prompt is longer, why four requests at once do not take four times as long, and why a request that asks for twice the answer costs twice the time. Nothing here is specific to llama.cpp or to Qwen; the

  4. GGUF, quantization, memory and threads

    The last lesson said that generating a token means reading every weight once. This one turns that into bytes and seconds for the model Larkmoor runs: what a GGUF file is, what the quantization in its name means, how much memory a runtime needs for its weights and its caches, and why the runtime is given three threads. By the end you can read the two numbers in compose.yaml that the gateway depends on, --ctx-size 8192 and --parallel 4, and say where they came from.

  5. Slots, batching and the prompt cache in llama.cpp's server

    llama-server is the program that executes the model. The lab runs it from llama.cpp's official container image, pinned by digest, twice: once per model file. This lesson explains what the server does with the flags in compose.yaml, what its endpoints return, and which of its metrics the dashboards and rules read. Everything the gateway asks of a runtime is here.

  6. Load a service honestly and read what it tells you

    "How fast is it?" has no answer without "under what load, measured how?" This lesson is about the second half of that sentence: the two ways to load a service and why only one of them can show overload, what a percentile is and which ones matter, how a histogram turns requests into a service level indicator, and one equation that tells you whether your measurement can be trusted. It ends with the report from the baseline milestone, read line by line.

  7. Bound the work, order it and reject the rest quickly

    The runtime has four slots. Everything the gateway does with the fifth request at a busy moment is admission control, and it is the part of the design that answers the storm-week failure directly: not "make the model faster" but "decide, quickly and visibly, what happens to work the service cannot do right now". This lesson explains the policy, reads the code that implements it, replays the storm, and compares two settings.

  8. Token budgets, response caching and prompt-cache affinity

    Admission control decides whether a request may use a slot. Two stages before it decide whether the request needs one at all: the response cache, which answers a repeated deterministic request without the runtime, and the token budget, which refuses a request that could not fit a slot. Both are cheap, which is why they run first. A third mechanism lives inside the runtime, the prompt cache, and the gateway's job there is to make its effect visible. This lesson covers all thre

  9. Schema-constrained output and the quantization gate

    The second storm-week failure was not about speed: a model-file upgrade silently renamed two fields in the claim record and broke downstream reports for a day. This lesson is about the two mechanisms that make that impossible to repeat, one at request time and one before a model file is allowed to serve: schema-constrained output, which makes the record's shape the gateway's decision rather than the model's, and the evaluation gate, which scores a model file on sixty notes wi

  10. Service level objectives, error budgets and burn-rate alerts

    A service level objective is a promise written as a number: "95% of interactive requests get their first token within two seconds." This lesson shows how the gateway's histograms become that number in Prometheus, how the number becomes an error budget, how the rate at which the budget is spent becomes an alert that fires during a storm and stays quiet during a blip, and why the lab's rule file and a production rule file differ only in their constants.

  11. Canary a model file and roll it back

    A model file is a deployment. The storm-week upgrade treated it as a file copy: all traffic, at once, with nobody watching the numbers that would have shown the change. This lesson is the alternative: weighted routing so that a share of traffic can go to a new file, pinning so that checks can target it, a procedure that moves the share in steps with a measured check between each, and a rollback that is one command. The script that does it reads the same metrics the dashboards

  12. From measurements to machines and cost per token

    "How many handlers can this machine serve?" and "what does a million tokens cost us?" are the two questions an inference engineer is asked most, and both have the same honest answer: measure, then divide, and show the division. This lesson finds the knee of the capacity curve with a rate sweep, turns it into handlers per machine with explicit assumptions, prices a million tokens from a machine's hourly cost, compares the two model files on that basis, and says what changes wh

  13. Run, measure, qualify and roll out the service

    This runbook takes the lab from an empty folder to a promoted model file in eight milestones, then cleanup removes everything it created. Every command runs on your own machine; nothing here touches a cloud account. Each section says what exists before it, what it creates, where the command runs, what a good result looks like and what to check when yours differs. Output shown in this page is an example of the shape to expect, not a recording of your run: your numbers will dif

  14. Reason from a symptom to the mechanism behind it

    Every lesson so far named a mechanism: prefill and decode, slots and the prompt cache, the scheduler's three rejections, the budget, the two caches, the grammar, the burn rate, the weight. Troubleshooting is the skill of going the other way, from a symptom a handler or a dashboard reports to the mechanism that produced it, with evidence at each step. The scenarios practise that in the form an interviewer uses: a symptom, what has been observed, and the question "what would yo

  15. Explain the design and defend its trade-offs

    An inference engineer is asked to explain decisions, not to recite tools: why a gateway, why two classes, why those SLO windows, why that check in the rollout, and what would change if a constraint moved. The twenty questions are written the way an interviewer asks them, around this project's design and every technology it uses, with model answers grounded in the code you have run.

  16. Remove the lab and check for leftovers

    The lab created containers, a network, two volumes, one local image and 1.17 GB of model files. This page removes them in that order, says what is kept on purpose, and checks that nothing is left. There is no cloud resource to delete and nothing here costs money to leave running, but a runtime left up holds 0.7 GB of memory and three CPUs' worth of limits, and the lesson is a clean host.

Practical build steps (9)
  1. Fetch the model files and prepare the inputs

    Before a single container runs, three things have to be true: the model files on disk are the ones the lab was built with, the secrets exist and are yours, and the gateway image was built from the reviewed lock. This milestone makes each of those true and checks it, and nothing in it can be undone badly: every step is repeatable.

  2. Start the stack and prove the path

    One command starts four containers in dependency order and returns when all of them are healthy; one script sends a request of each kind and shows you the headers and timings that the rest of the project is about. This milestone ends with a working service and your first look at what the gateway measures.

  3. Measure the baseline and set the targets

    Nothing about a service's capacity can be known from its configuration. This milestone sends a quiet afternoon's traffic for two minutes, reads the report, and checks the SLO targets against what the service actually does when nothing is wrong. Every later milestone compares against this run.

  4. Replay the storm

    The week that started this project, replayed in three minutes: a minute of arrivals at five times the quiet rate between two quiet periods. You watch the queue fill, the scheduler start rejecting, and the burn-rate alert fire, then read a report that shows the storm as outcomes rather than as missing data.

  5. Tune admission control and measure again

    Two numbers in config/gateway.yaml decide how a storm feels to a handler: how many requests may wait, and how long. This milestone changes them, replays the same storm, and puts the two reports side by side. The lesson is not which setting is right but how to argue for one.

  6. Start the candidate and run the evaluation gate

    The cheaper model file, Q4_K_M, is 27% smaller than the current Q8_0 and generates faster. Whether it is good enough for Larkmoor's claim records is a question with a method behind it: sixty notes with exact answers, scored field by field, against floors and against the current model. This milestone starts the second runtime and asks that question.

  7. Canary the candidate

    Moving traffic to a new model file is where the storm-week upgrade went wrong: all at once, with nobody watching the right numbers. This milestone moves it in three steps with a measured check between each, and rolls back on the first check that fails. The script that does it reads the same metrics the rollout dashboard shows, so you can watch its reasoning.

  8. Capacity and cost

    "How many handlers can this machine serve?" and "what does a million tokens cost?" are the two questions a serving team is asked most, and both have the same answer: measure, then divide. This milestone sweeps the arrival rate to find where the service stops meeting its objectives, and turns the measured throughput into a cost per million tokens from a price you supply.

  9. Remove the lab and check for leftovers

    The lab created containers, a network, two volumes, an image and 1.17 GB of model files, all on your machine. Removing them is one command plus a check, and the check is the habit worth keeping: a cleanup that is not verified is a guess.

Access

Learning Access: INR 199 plus 18% GST. Source Pack: INR 399 plus 18% GST. 90 days of online access. No auto-renewal.

Cloud costs and boundaries

There is no cloud cost: every component runs in containers on your own machine, and the only downloads are two Apache-2.0 model files (1.17 GB) and pinned container images. Electricity is the running cost. If you choose to run the lab on a rented virtual machine you pay that provider's hourly price and must stop the machine afterwards; the capacity lesson uses such a price only as an input to the cost arithmetic and names no provider. This is a learning reference, not a hosted lab or a production-readiness guarantee.

Licence and completion

Vectametric Project Source Licence (2026-09-27): lawfully obtained source may be copied, modified and deployed for personal learning and interview preparation, including personal portfolio demonstrations with attribution. These permissions continue after online access expires. Do not resell or redistribute the Source Pack or its original source files, unchanged or modified. Commercial or client production use requires separate written permission. Third-party components, such as llama.cpp, Qwen2.5-0.5B-Instruct, FastAPI, Uvicorn, httpx, prometheus_client, pydantic, PyYAML, pytest, ruff, Prometheus and Grafana, retain their own licences; the model files are downloaded by the learner and are not part of the Source Pack. See LICENSE.txt and the Project Source Licence section of the site Terms for the full rules.

Questions about projects

Do I need a cloud account?

You can read the project material without deploying it. Running a cloud build requires the accounts, permissions and tools listed in that project's prerequisites. Deployment runs in your environment, not in a hosted Vectametric lab.

Can I read the code with Learning Access?

Yes. Learning Access includes the online source-file browser and explanations. The Source Pack adds the downloadable reference repository where available. The project's licence governs use of the source.

Are cloud charges included?

No. Cloud and CI usage are separate. Read the project's cost notice, set a budget and stop deadline, and follow its destruction and leftover-resource checks.

Does the project include troubleshooting and interview preparation?

The project curriculum lists the available scenarios and interview topics. These focus on understanding the architecture and explaining decisions; they are not a promise of particular interview questions or a job.

How long can I use the project?

The project page and checkout show the online access period for your selected plan. Access does not auto-renew. Downloaded source remains subject to its licence; future releases are not automatically included.

Review the Terms and No-Refund Policy before confirming access. All sales are final; Vectametric does not offer refunds.

This website is operated by VECTAMETRIC EDTECH (OPC) PRIVATE LIMITED, operating as Vectametric.

Corporate Identity Number (CIN): U85499KA2026OPC229822. GSTIN: 29AAMCV8281D1ZS. Registered office: RS NO/38/2A/1 BASTAND, ROAD MAHANTESH NAGAR, Ramdurg, Ramdurg, Belgaum- 591123, Karnataka.

Queries and grievances: Prajval Honnungar, Grievance Officer and Data Protection Contact.

Telephone: +91 94800 09310. Support: support@vectametric.com. Grievances: support@vectametric.com.

Copyright 2026 VECTAMETRIC EDTECH (OPC) PRIVATE LIMITED. All rights reserved.

Vectametric home · Roadmaps · Vecta IT Exams · Vecta Government Exams · Vecta Banking & Finance Exams · Vecta Entrance Exams · About us · Contact · Privacy Policy · Terms and Conditions · No-Refund Policy