Dev.to AI 🤖 Ai 👁 0

Why your .NET AI request is slow: a segment-by-segment teardown

A support assistant answers in eight seconds. The HTTP span says 200 OK. The database span is fast. The LLM span is "slow". None of that tells you whether the time went into DNS, TLS, uploading the prompt, provider queue

A support assistant answers in eight seconds. The HTTP span says 200 OK. The database span is fast. The LLM span is "slow". None of that tells you whether the time went into DNS, TLS, uploading the prompt, provider queueing, the first token, or streaming the answer.

General APM was designed for request/response services. LLM calls have a different shape:

  • A long-lived streaming response, where time-to-first-token matters more than total duration.
  • A cost dimension that general APM does not model.
  • Provider-side queueing that looks like "network" unless you separate it.
  • Retries that can silently double the bill.

Runesvaner is an in-process profiler for .NET AI workloads. This post walks through the measurement model and the numbers behind it — including what cannot be measured.

Six segments, measured where possible

Segment What it means Source
Queue Middleware and serialization before the HTTP call Stopwatch
Connect DNS + TCP connection SocketsHttpHandler.ConnectCallback
Upload Request body serialization HttpContent wrapper
ProviderQueue Wait for response headers Stopwatch
TTFT First non-empty text delta MEAI decorator
Generation Response stream until EOF Stream wrapper

Canonical URL

📰 Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.