{"slug": "why-your-net-ai-request-is-slow-a-segment-by-segment-teardown", "title": "Why your .NET AI request is slow: a segment-by-segment teardown", "summary": "A developer built Runesvaner, an in-process profiler for .NET AI workloads that breaks a slow LLM request into six timed segments: queue, connect, upload, provider queue, time-to-first-token, and generation. The tool instruments each stage separately—using a Stopwatch, SocketsHttpHandler.ConnectCallback, an HttpContent wrapper, a MEAI decorator, and a stream wrapper—because general APM spans only flag the LLM call as \"slow\" without showing where the time went.", "body_md": "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.\n\nGeneral APM was designed for request/response services. LLM calls have a different shape:\n\nRunesvaner 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.\n\n| Segment | What it means | Source | \n|---|---|---|\n| Queue | Middleware and serialization before the HTTP call | Stopwatch | \n| Connect | DNS + TCP connection | `SocketsHttpHandler.ConnectCallback` | \n| Upload | Request body serialization | `HttpContent` wrapper | \n| ProviderQueue | Wait for response headers | Stopwatch | \n| TTFT | First non-empty text delta | MEAI decorator | \n| Generation | Response stream until EOF | Stream wrapper |", "url": "https://wpnews.pro/news/why-your-net-ai-request-is-slow-a-segment-by-segment-teardown", "canonical_source": "https://dev.to/karlmoriaty/why-your-net-ai-request-is-slow-a-segment-by-segment-teardown-5f4o", "published_at": "2026-11-28 11:41:57+00:00", "updated_at": "2026-11-28 11:43:40.160218+00:00", "lang": "en", "topics": ["ai-tools", "developer-tools", "large-language-models", "mlops", "ai-infrastructure"], "entities": ["Runesvaner", ".NET", "MEAI", "SocketsHttpHandler"], "also_reported_by": [], "takeaway": "Instrument LLM calls in six separate segments—queue, connect, upload, provider queue, TTFT, and generation—rather than treating the whole call as one slow span.", "recommendation": {"advice": "Break LLM request latency into queue, connect, upload, provider-queue, TTFT and generation segments so you can pinpoint whether DNS, upload, provider queueing or streaming is the bottleneck.", "playbook": "production-ops", "playbook_url": "https://wpnews.pro/playbooks/production-ops"}, "alternates": {"html": "https://wpnews.pro/news/why-your-net-ai-request-is-slow-a-segment-by-segment-teardown", "markdown": "https://wpnews.pro/news/why-your-net-ai-request-is-slow-a-segment-by-segment-teardown.md", "text": "https://wpnews.pro/news/why-your-net-ai-request-is-slow-a-segment-by-segment-teardown.txt", "jsonld": "https://wpnews.pro/news/why-your-net-ai-request-is-slow-a-segment-by-segment-teardown.jsonld"}}