Zum Hauptinhalt springen
Echtzeit-Radar & Feeds
Alle RSS Feeds ➔
👥 Community & Social
YouTube Security VideosTechLinked: Apple says no more upgradeability(25.09.2026 um 01:02 Uhr)
•
Podcasts & Audio BriefingsiPhone 18, iPhone Duo und AirPods auf dem Prüfstand | CHIP.Chat #44(25.09.2026 um 00:00 Uhr)
•
YouTube Security VideosGoogle Cloud Tech: A Developer’s Guide to Gemini 3.5 Transcribe(25.09.2026 um 01:00 Uhr)
••••••••
YouTube Security VideosTechLinked: Apple says no more upgradeability(25.09.2026 um 01:02 Uhr)
•
Podcasts & Audio BriefingsiPhone 18, iPhone Duo und AirPods auf dem Prüfstand | CHIP.Chat #44(25.09.2026 um 00:00 Uhr)
•
YouTube Security VideosGoogle Cloud Tech: A Developer’s Guide to Gemini 3.5 Transcribe(25.09.2026 um 01:00 Uhr)
••••••••
Intelligence View
⚡ tsecurity.de Intelligence

# Beyond Round Robin: Building a Token-Aware Load Balancer for LLMs

In my previous experiment, I was trying to find the best model for a given task. The approach was to send the same request to multiple LLM models in parallel and return whichever responded first. Users got faster responses, but every…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

In my previous experiment, I was trying to find the best model for a given task. The approach was to send the same request to multiple LLM models in parallel and return whichever responded first. Users got faster responses, but every request burned GPU cycles across multiple servers, most of which went to waste.



That raised an obvious question: instead of racing backends against each other, what if the load balancer could pick the right one upfront?






Why Traditional Load Balancing Breaks Down for LLMs



Standard load balancers route traffic using Round Robin, Least Connections, or health-based metrics. These strategies assume requests have roughly equal cost. That assumption breaks with LLMs.



A 10-token prompt ("Translate 'hello' to French") and a 4,000-token prompt ("Analyze this codebase") both count as one connection. Least Connections will happily stack three heavy prompts on one server while another sits idle. The result is head-of-line blocking on the overloaded node, and wasted capacity elsewhere.



Connection count is not a proxy for computational cost. Token count is.






The Insight



LLM inference has two phases: prefill (processing the input prompt) and decode (generating tokens sequentially). Prefill time scales directly with input token count. A 4,000-token prompt consumes significantly more GPU time during prefill than a 10-token one.



If the balancer can estimate token count before routing, it can maintain a running total of in-flight tokens per backend and route to the node with the lowest total. Same Least Loaded pattern used in distributed systems, but the metric is tokens instead of connections. The algorithm becomes: pick the backend where current_in_flight_tokens + new_request_tokens is the lowest.






Architecture



I built this as an L7 reverse proxy in Go, sitting between clients and a cluster of LLM backends.



Token Aware Load balancermermaid



The request lifecycle:





  1. Intercept the incoming JSON body and extract the prompt


  2. Tokenize using a tiktoken-compatible encoder


  3. Route to the backend with the lowest in-flight token count


  4. Increment that backend's token counter before proxying


  5. Forward the request through httputil.ReverseProxy


  6. Decrement the counter once the backend responds



I chose Go because net/http, httputil.ReverseProxy, and sync/atomic cover almost everything needed here. The only external dependency is tiktoken-go for tokenization.






The Body-Read Problem



In Go, r.Body is an io.ReadCloser. It can only be read once. The balancer needs to read it for tokenization and still forward the original payload to the backend.



The fix: read the body into a []byte, run the tokenizer against that slice, then reassign r.Body with io.NopCloser(bytes.NewReader(body)). The downstream proxy sees an intact body.



This is a well-known concern in any L7 proxy that inspects payloads, but it is easy to overlook when you are building one for the first time.






Separating Middleware from RoundTripper



Token aware load balancer splits its logic across two layers.



Middleware (http.Handler wrapper) handles request validation, error responses (400, 503), and stores the computed token count in the request context. Anything that might reject a request lives here.



RoundTripper (http.RoundTripper implementation) handles transport-level concerns: setting the destination URL and managing the token counter lifecycle. The decrement happens after the backend response is received, which maps naturally to the RoundTrip call boundary.






Results



I ran both strategies against the same setup: 3 backend servers where each simulates LLM compute time by sleeping proportionally to the input token count (±20% jitter to mimic real variance). Three payload sizes were used: small (~30ms), large (~2750ms), and huge (~7500ms). Traffic is mixed, with each request randomly picking a payload size.






High Contention (50% heavy, 50% small, concurrency=30, 60 requests)


























Metric Round Robin Token Aware Improvement
Average Latency 2.58s 2.27s -12%
P90 Latency 8.60s 7.78s -10%





Heavy Workload (80% heavy, 20% small, concurrency=5, 60 requests)


























Metric Round Robin Token Aware Improvement
Average Latency 4.45s 4.20s -6%
P90 Latency 8.67s 8.57s -1%


The gains are most visible under high contention. At concurrency=30, average latency drops 12% and P90 drops 10%. The reason is straightforward: small requests no longer get stuck behind heavy ones because the balancer routes by computational weight, not connection count.



A 12% improvement across 3 simulated backends is a floor, not a ceiling. Real workloads with wider token variance and higher concurrency would amplify the difference.






What's Next



This is a simplified implementation. Production systems would need health checks with automatic backend removal, streaming (SSE) support with per-chunk token tracking, output token estimation for more accurate load prediction, and observability through Prometheus or equivalent.



The code is on GitHub.

SOC Incident Playbook: Remote Code Execution (RCE) Defense
Syntax validiert (0 Fehler)
title: Detect Exploitation - # Beyond Round Robin: Building a Token-Aware Load Balancer for LLMs
id: 80a17422-9118-4d91-b3e8-da1b827fb3c3
status: experimental
description: Automatisch generierte SIEM-Erkennungsregel basierend auf CTI Intelligence
references:
  - https://tsecurity.de/
author: iShareStuff CTI Automated Detection Engine
date: 2026-09-25
logsource:
  category: network_connection
  product: any
detection:
  selection:
      CommandLine|contains:
        - 'exploit'
  condition: selection
falsepositives:
  - Legitime administrative Zugriffe oder Penetrationstests
level: high
tags:
  - attack.initial_access
Syntax validiert (0 Fehler)
rule CTI_Threat_Indicator {
    meta:
        author = "iShareStuff CTI Automated Detection Engine"
        date = "2026-09-25"
        description = "YARA Signature for "
    strings:
        $str = "# Beyond Round Robin: Building" ascii wide
    condition:
        any of them
}
Syntax validiert (0 Fehler)
index=security sourcetype IN ("cisco:asa", "pan:traffic", "zeek_conn", "suricata", "WinEventLog:Security")
("Beyond Round Robin Building a Token-Awar")
| stats count earliest(_time) as first_seen latest(_time) as last_seen by src_ip, dest_ip, dest_host, signature
| eval first_seen=strftime(first_seen, "%Y-%m-%d %H:%M:%S"), last_seen=strftime(last_seen, "%Y-%m-%d %H:%M:%S")
| sort - count
Syntax validiert (0 Fehler)
message: "*Beyond Round Robin Building a Token-Awar*"
Syntax validiert (0 Fehler)
CommonSecurityLog
| where Message has "Beyond Round Robin Building a Token-Awar"
| summarize EventCount = count(), FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated) by SourceIP, DestinationIP, DestinationPort, Activity
| extend DetectionRule = "iShareStuff-CTI-Compiled"
| sort by EventCount desc
🎯
MITRE ATT&CK Matrix Navigator 14 Taktiken
Reconnaissance
-
Resource Development
-
Initial Access
Execution
Persistence
-
Privilege Escalation
Defense Evasion
Credential Access
-
Discovery
-
Lateral Movement
-
Collection
-
Command and Control
Exfiltration
-
Impact
tsecurity.de Cognitive Threat RAG
Fokus-Vektor:

Kognitive Analyse für identifizierte Bedrohung: Erhöhte Bedrohungslage im Bereich # Beyond Round Robin: Building a Token-A.... Basierend auf 368k Vektor-Korrelationen werden sofortige Isolationsmaßnahmen für betroffene Endpunkte empfohlen.

🛡️ Angriffsfläche & Exposure

Netzwerk/Remote-Zugriff ohne Vorauthentifizierung möglich.

⚡ Empfohlene Sofortmaßnahmen
  • 1. Perimeter-Inspektion: Relevante Portfreigaben und exponierte Endpunkte unverzüglich scannen.
  • 2. Patch-Applikation: Hersteller-Hotfix einspielen oder betroffene Daemons in isolierte DMZ-Segmente überführen.
  • 3. Telemetrie & EDR-Alerts: Prozessaufrufe und Child-Processes auf anomale Shell-Spawns überwachen.
🔗 Semantisch verwandte Zero-Days MariaDB 11.7 VEC
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten # Beyond Round Robin: Building a Token-Aware Load Balancer for LLMs

Thematisch verwandte Begriffe: Beyond, Round, Robin, Building · 6 Treffer

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-87722 | Uncontrolled Resource Consumption (CWE-400 / CWE-1333) in regex search q…
Advisory →
tsecurity.de Icon
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel • Rechts: nächster Artikel • unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel TTP ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...
↗ Original-Quelle