Skip to main content
ARCHOS 525 BLUEPRINT · /d/dgm_llm-prefill-decode-and-batching

LLM serving: prefill, decode and batching

13 COMPONENTS · 14 FLOWS · UPDATED 2026-11-21
GITHUB README / PR PREVIEW CARD
[![LLM serving: prefill, decode and batching — ArchOS Architecture](https://archos.sageideas.dev/d/dgm_llm-prefill-decode-and-batching/opengraph-image)](https://archos.sageideas.dev/d/dgm_llm-prefill-decode-and-batching)

*Interactive architecture diagram powered by [ArchOS Studio](https://archos.sageideas.dev/d/dgm_llm-prefill-decode-and-batching)*
NOTION / DOCS / CONFLUENCE EMBED
<iframe src="https://archos.sageideas.dev/embed/dgm_llm-prefill-decode-and-batching" width="100%" height="580" style="border:1px solid rgba(240,236,225,0.14);border-radius:6px;" loading="lazy" title="LLM serving: prefill, decode and batching — Interactive in ArchOS"></iframe>
PORTABLE MERMAID SPEC (GITHUB / NOTION / RFC)
flowchart LR
  client_0[("Chat client")]
  pdp_1["Policy decision point (PDP)"]
  gw_2["API gateway"]
  secrets_3[("Secrets manager")]
  tsdb_4[("Time-series database (TSDB)")]
  alerting_5[("Alerting")]
  prefix_6["Prompt prefix caching"]
  batch_7["Continuous batching"]
  prefill_8[("Prefill step")]
  kv_9["KV cache"]
  decode_10[("Decode step")]
  srvb_11["Inference server"]
  capacity_12["Capacity Estimate"]
  client_0 -->|"1. Sends JWT · HTTPS"| gw_2
  gw_2 -->|"2. Forwards · HTTPS"| batch_7
  batch_7 -->|"3. Looks up prefix · TCP"| prefix_6
  prefix_6 -->|"4. New part · TCP"| prefill_8
  prefill_8 -->|"5. Writes blocks · TCP"| kv_9
  kv_9 -->|"6. Reads blocks · TCP"| decode_10
  decode_10 -->|"7. Next token · TCP"| batch_7
  batch_7 -->|"8. Tokens · HTTPS"| gw_2
  gw_2 -->|"9. Tokens · HTTPS"| client_0
  gw_2 -->|"Asks policy · HTTPS"| pdp_1
  gw_2 -->|"Fetches key · HTTPS"| secrets_3
  gw_2 -->|"Fallback · HTTPS"| srvb_11
  tsdb_4 -->|"Scrapes engine · HTTPS"| batch_7
  tsdb_4 -->|"Metrics · HTTP"| alerting_5

COMPONENT STACK (12)

  • Chat clientSTATEFUL
    Sends a prompt, reads streamed tokens
  • Policy decision point (PDP)STATELESS
    Which tenant may use which model
  • API gatewaySTATELESS
    Checks the JWT, caps requests in flight
  • Secrets managerSTATEFUL
    Holds the gateway TLS key
  • Time-series database (TSDB)STATEFUL
    Stores queue depth and KV cache usage
  • AlertingSTATEFUL
    Pages on a long queue or a full KV cache
  • Prompt prefix cachingSTATELESS
    Reuses keys and values of a shared prompt start
  • Continuous batchingSTATELESS
    Admits and retires requests every decoding step
  • Prefill stepSTATEFUL
    Processes the new prompt tokens in one pass
  • KV cacheSTATELESS
    Paged blocks in GPU memory; the batch size limit
  • Decode stepSTATEFUL
    Adds one token per request each step
  • Inference serverSTATELESS
    Second replica; same design as zone a

REQUEST & DATA FLOW (14)

  1. Chat client → API gateway (Sends JWT)[HTTPS]
  2. API gateway → Continuous batching (Forwards)[HTTPS]
  3. Continuous batching → Prompt prefix caching (Looks up prefix)[TCP]
  4. Prompt prefix caching → Prefill step (New part)[TCP]
  5. Prefill step → KV cache (Writes blocks)[TCP]
  6. KV cache → Decode step (Reads blocks)[TCP]
  7. Decode step → Continuous batching (Next token)[TCP]
  8. Continuous batching → API gateway (Tokens)[HTTPS]
  9. API gateway → Chat client (Tokens)[HTTPS]
  10. API gateway → Policy decision point (PDP) (Asks policy)[HTTPS]
  11. API gateway → Secrets manager (Fetches key)[HTTPS]
  12. API gateway → Inference server (Fallback)[HTTPS]
  13. Time-series database (TSDB) → Continuous batching (Scrapes engine)[HTTPS]
  14. Time-series database (TSDB) → Alerting (Metrics)[HTTP]
Configure NGINX / Postgres / K8s →60-Sec L4–L7 Diagnostic →