{"id":477187,"date":"2026-04-24T04:19:58","date_gmt":"2026-04-24T04:19:58","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=477187"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=477187","title":{"rendered":"\u041a\u0430\u043a \u043c\u044b \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043b\u0438 vLLM \u00ab\u043b\u0435\u043d\u0438\u0442\u044c\u0441\u044f\u00bb \u043f\u043e\u0434 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u0438 \u0441\u043f\u0430\u0441\u043b\u0438 Time-to-First-Token"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h4>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435: \u041f\u043e\u0447\u0435\u043c\u0443 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 Rate Limiting \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0434\u043b\u044f LLM?<\/h4>\n<p>\u0414\u0435\u043f\u043b\u043e\u0439 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u044f\u0437\u044b\u043a\u043e\u0432\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 (LLM) \u2014 \u044d\u0442\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u043e\u043b\u044c, \u043a\u043e\u0433\u0434\u0430 \u0434\u0435\u043b\u043e \u0434\u043e\u0445\u043e\u0434\u0438\u0442 \u0434\u043e \u043f\u0438\u043a\u043e\u0432\u044b\u0445 \u043d\u0430\u0433\u0440\u0443\u0437\u043e\u043a. \u0412 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0445 web-\u0441\u0435\u0440\u0432\u0438\u0441\u0430\u0445 \u043f\u0440\u0438 \u0432\u044b\u0441\u043e\u043a\u0438\u0445 RPS \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0449\u0438\u043a, \u0430 \u0435\u0441\u043b\u0438 \u0432\u0441\u0451 \u0433\u043e\u0440\u0438\u0442 \u2014 \u0436\u0435\u0441\u0442\u043a\u043e \u0440\u0435\u0436\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u044b <code>HTTP 429 Too Many Requests<\/code>.<\/p>\n<p>\u041d\u043e \u0432 \u043c\u0438\u0440\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0433\u043e AI \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u043e\u0447\u0435\u043d\u044c \u0434\u043e\u0440\u043e\u0433\u043e: \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0443\u0436\u0435 \u043f\u043e\u0434\u043e\u0436\u0434\u0430\u043b, \u043f\u043e\u043a\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u0441\u044f \u0447\u0430\u0442, \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0434\u043b\u0438\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u043c\u043f\u0442, \u043d\u0430\u0436\u0430\u043b Enter \u0438\u2026 \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u043e\u0448\u0438\u0431\u043a\u0443. \u0410 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 GPU-\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043c\u0438\u043d\u0443\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0443 \u043d\u0430\u0441 \u043d\u0435\u0442.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043f\u043e\u043a\u0430\u0436\u0435\u043c, \u043a\u0430\u043a \u043f\u043e\u0434\u0445\u043e\u0434 <strong>\u201c\u0414\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043b\u0435\u043d\u0438\u201d<\/strong> (Dynamic Degradation) \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043f\u0440\u0438 100% \u0443\u0442\u0438\u043b\u0438\u0437\u0430\u0446\u0438\u0438 GPU, \u043d\u0435 \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0430 \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u0441\u0430\u043c\u0443 \u043c\u043e\u0434\u0435\u043b\u044c \u0431\u044b\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u201c\u043a\u0440\u0430\u0442\u043a\u043e\u0439\u201d. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0441\u0432\u043e\u0439 open-source \u0448\u043b\u044e\u0437 <a href=\"https:\/\/github.com\/malakhovskiy\/LazyGate\" rel=\"noopener noreferrer nofollow\">LazyGate<\/a>.<\/p>\n<hr\/>\n<h4>\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 LazyGate<\/h4>\n<p>\u0418\u0434\u0435\u044f \u043f\u0440\u043e\u0441\u0442\u0430: \u043c\u044b \u0441\u0442\u0430\u0432\u0438\u043c \u043f\u0435\u0440\u0435\u0434 \u043d\u0430\u0448\u0438\u043c vLLM \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c \u043b\u0435\u0433\u043a\u043e\u0432\u0435\u0441\u043d\u044b\u0439 ASGI-\u043f\u0440\u043e\u043a\u0441\u0438 \u043d\u0430 \u0431\u0430\u0437\u0435 <code>FastAPI<\/code> + <code>httpx<\/code>. \u042d\u0442\u043e\u0442 \u043f\u0440\u043e\u043a\u0441\u0438-\u0448\u043b\u044e\u0437 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043e\u0434\u043d\u0443 \u043a\u043b\u044e\u0447\u0435\u0432\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u2014 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u043e\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u044b NVIDIA (\u0438\u043b\u0438 \u044d\u043c\u0443\u043b\u044f\u0442\u043e\u0440 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438), \u043f\u043e\u043b\u0443\u0447\u0430\u044f \u043c\u0435\u0442\u0440\u0438\u043a\u0443 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0430 <code>GPU<\/code>.<\/p>\n<p>\u041c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u0442\u0440\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430:<\/p>\n<ol>\n<li>\n<p><strong>Normal Load (&lt;75%)<\/strong>: \u041e\u0431\u044b\u0447\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c. \u041c\u043e\u0434\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0442\u0438\u0445\u0438, \u0434\u043e\u043b\u0433\u043e \u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0430\u0442\u044c \u0438 \u0432\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0434\u0435\u0442\u0430\u043b\u0438 (max_tokens: 100%).<\/p>\n<\/li>\n<li>\n<p><strong>Tired Load (75-90%)<\/strong>: \u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0438\u0441\u043f\u044b\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 (\u043e\u0447\u0435\u0440\u0435\u0434\u044c continuous batching \u0440\u0430\u0441\u0442\u0435\u0442). \u041f\u0440\u043e\u043a\u0441\u0438 \u201c\u043d\u0430 \u043b\u0435\u0442\u0443\u201d \u043f\u043e\u0434\u043a\u0438\u0434\u044b\u0432\u0430\u0435\u0442 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 <code>messages<\/code> \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u043f\u0440\u043e\u043c\u043f\u0442: <em>\u201c\u041e\u0442\u0432\u0435\u0447\u0430\u0439 \u043a\u0440\u0430\u0442\u043a\u043e\u201d<\/em>, \u0430 <code>max_tokens<\/code> \u0443\u0440\u0435\u0437\u0430\u0435\u0442\u0441\u044f \u0434\u043e 70%.<\/p>\n<\/li>\n<li>\n<p><strong>Extremely Lazy (&gt;90%)<\/strong>: \u0410\u0432\u0430\u0440\u0438\u0439\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c. \u0427\u0442\u043e\u0431\u044b \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u043e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u043e\u0447\u0435\u0440\u0435\u0434\u044c KV-\u043a\u044d\u0448\u0430, \u0448\u043b\u044e\u0437 \u0438\u043d\u0436\u0435\u043a\u0442\u0438\u0442 \u0436\u0435\u0441\u0442\u043a\u0438\u0439 \u043f\u0440\u043e\u043c\u043f\u0442: <em>\u201cProvide extremely short answers only. No explanations. Code only if asked.\u201d<\/em> \u0438 \u0440\u0435\u0436\u0435\u0442 \u0442\u043e\u043a\u0435\u043d\u044b \u0434\u043e 30%.<\/p>\n<\/li>\n<\/ol>\n<h3>Zero-Blocking \u043f\u043e\u043b\u043b\u0438\u043d\u0433 NVML<\/h3>\n<p>\u0427\u0438\u0442\u0430\u0442\u044c \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0432\u0438\u0434\u0435\u043e\u043a\u0430\u0440\u0442\u044b \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c HTTP \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0447\u0435\u0440\u0435\u0437 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 Python <code>pynvml<\/code> \u2014 \u0432\u0435\u0440\u043d\u0430\u044f \u0441\u043c\u0435\u0440\u0442\u044c \u0434\u043b\u044f Event Loop\u2019\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0432\u044b\u043d\u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0432 \u0444\u043e\u043d\u043e\u0432\u0443\u044e <code>asyncio<\/code> \u0437\u0430\u0434\u0430\u0447\u0443.<\/p>\n<pre><code class=\"python\"># \u0418\u0437 \u043d\u0430\u0448\u0435\u0433\u043e hardware.pyasync def _monitor_loop(self):    while True:        # \u0427\u0442\u0435\u043d\u0438\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 (\u043b\u0438\u0431\u043e \u0441\u0438\u043d\u0443\u0441\u043e\u0438\u0434\u044b \u0434\u043b\u044f mock \u0440\u0435\u0436\u0438\u043c\u0430)        new_load = self._fetch_real_load()                # EMA (\u042d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0435 \u0441\u0440\u0435\u0434\u043d\u0435\u0435) \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0431\u043e\u0440\u043e\u0442\u044c \"\u0434\u0440\u0435\u0431\u0435\u0437\u0433\" \u043d\u0430 \u043f\u043e\u0440\u043e\u0433\u0430\u0445        alpha = 0.3        self._current_load = (new_load * alpha) + (self._current_load * (1 - alpha))                    await asyncio.sleep(self.update_interval)<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:87px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0440\u043e\u0443\u0442\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e <img decoding=\"async\" class=\"formula inline\" source=\"O(1)\" alt=\"O(1)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/5\/5e\/5e0\/5e079a28737d5dd019a3b8f6133ee55e.svg\" width=\"32\" height=\"16\" data-width=\"4.618\" data-height=\"2.262\" data-vertical-align=\"-0.566\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/5\/5e\/5e0\/5e079a28737d5dd019a3b8f6133ee55e.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/5\/5e\/5e0\/5e079a28737d5dd019a3b8f6133ee55e.svg 781w\" loading=\"lazy\" decode=\"async\"\/> \u0447\u0442\u0435\u043d\u0438\u0435 \u0438\u0437 \u043f\u0430\u043c\u044f\u0442\u0438: <code>monitor.current_load<\/code>.<\/p>\n<hr\/>\n<h4>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441\u043e \u0441\u0442\u0440\u0438\u043c\u0438\u043d\u0433\u043e\u043c \u0438 SSE<\/h4>\n<p>vLLM \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0441\u043e \u0441\u0442\u0440\u0438\u043c\u0438\u043d\u0433\u043e\u043c \u0442\u043e\u043a\u0435\u043d\u043e\u0432 (<code>stream=True<\/code>). \u0415\u0441\u043b\u0438 \u0431\u044b \u043d\u0430\u0448 \u043f\u0440\u043e\u043a\u0441\u0438 \u0431\u0443\u0444\u0435\u0440\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043b \u043e\u0442\u0432\u0435\u0442, \u043c\u044b \u0431\u044b \u0443\u0431\u0438\u043b\u0438 \u0433\u043b\u0430\u0432\u043d\u0443\u044e \u0444\u0438\u0447\u0443 \u2014 <code>Time-to-First-Token (TTFT)<\/code>.<\/p>\n<p>\u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u0443\u044e \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0447\u0435\u0440\u0435\u0437 <code>StreamingResponse<\/code>:<\/p>\n<pre><code class=\"python\"># main.pyif is_stream:    async def stream_generator():        async with http_client.stream(\"POST\", url, json=body, headers=proxy_headers) as response:            async for chunk in response.aiter_bytes():                yield chunk                    return StreamingResponse(stream_generator(), media_type=\"text\/event-stream\")<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<hr\/>\n<h4>AI \u043a\u0430\u043a \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u0441\u0432\u043e\u0435\u0439 \u0436\u0435 \u201c\u041b\u0435\u043d\u0438\u201d (\u0410\u0432\u0442\u043e\u043d\u043e\u043c\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b)<\/h4>\n<p>\u041c\u044b \u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u0438 \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c Pytest-\u0442\u0435\u0441\u0442\u044b \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0444\u0438\u043b\u044c \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0432 <code>config.yaml<\/code>. \u0422\u0430\u043a \u043a\u0430\u043a \u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043c\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c AI-\u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b, \u043c\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0441\u043a\u0440\u0438\u043f\u0442 <code>tester_<\/code><a href=\"http:\/\/agent.py\" rel=\"noopener noreferrer nofollow\"><code>agent.py<\/code><\/a>.<\/p>\n<p>\u042d\u0442\u043e \u201c\u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u0410\u0433\u0435\u043d\u0442\u201d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0430\u043c \u0447\u0438\u0442\u0430\u0435\u0442 \u043a\u043e\u043d\u0444\u0438\u0433 YAML \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u043f\u043e\u0440\u043e\u0433\u043e\u0432, \u0438\u0434\u0435\u0442 \u0432 \u0444\u0430\u0439\u043b \u0441 Pytest-\u0442\u0435\u0441\u0442\u0430\u043c\u0438 \u0447\u0435\u0440\u0435\u0437 Abstract Syntax Trees (AST) \u0438 \u0438\u0449\u0435\u0442, \u043f\u043e\u043a\u0440\u044b\u0442 \u043b\u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 (Normal, Tired, Lazy). \u0415\u0441\u043b\u0438 \u043e\u043d \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u201c\u0434\u044b\u0440\u0443\u201d, \u0441\u043a\u0440\u0438\u043f\u0442 <em>\u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u043a\u043e\u0434<\/em> \u043d\u043e\u0432\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430 \u0432 \u0444\u0430\u0439\u043b <code>test_<\/code><a href=\"http:\/\/main.py\" rel=\"noopener noreferrer nofollow\"><code>main.py<\/code><\/a> \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440 \u0437\u0430\u043d\u043e\u0432\u043e!<\/p>\n<hr\/>\n<h4>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h4>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u043c\u043f\u0442\u0438\u043d\u0433\u0430 \u0434\u043b\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 (LLM Routing) \u2014 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u0435\u0435 \u0433\u0438\u0431\u043a\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434, \u0447\u0435\u043c \u0436\u0435\u0441\u0442\u043a\u0438\u0439 Rate-limiting.<\/p>\n<p>\u0412 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0445 \u043f\u043b\u0430\u043d\u0430\u0445 \u2014 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u0448\u043b\u044e\u0437 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u0435 Token Velocity (<img decoding=\"async\" class=\"formula inline\" source=\"T\/s\" alt=\"T\/s\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/6\/64\/64d\/64d8099ce6e4f7f6bbd8e96f8886b9d3.svg\" width=\"24\" height=\"16\" data-width=\"3.785\" data-height=\"2.262\" data-vertical-align=\"-0.566\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/6\/64\/64d\/64d8099ce6e4f7f6bbd8e96f8886b9d3.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/6\/64\/64d\/64d8099ce6e4f7f6bbd8e96f8886b9d3.svg 781w\" loading=\"lazy\" decode=\"async\"\/>) \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u043f\u0438\u043d\u0433\u0430 NVML, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043d\u0443\u044e \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u043e\u0447\u0435\u0440\u0435\u0434\u0435\u0439 vLLM.<\/p>\n<p>\u041a\u043e\u0434 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u0442\u043a\u0440\u044b\u0442 \u043f\u043e\u0434 \u043b\u0438\u0446\u0435\u043d\u0437\u0438\u0435\u0439 \u0434\u043b\u044f \u0430\u043a\u0430\u0434\u0435\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0438 \u043d\u0435\u043a\u043e\u043c\u043c\u0435\u0440\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 <a href=\"https:\/\/github.com\/malakhovskiy\/LazyGate\" rel=\"noopener noreferrer nofollow\">\u043d\u0430\u0448\u0435\u043c GitHub<\/a>. \u041f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0439\u0442\u0435\u0441\u044c!<\/p>\n<\/div>\n<p>\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/1027288\/\">https:\/\/habr.com\/ru\/articles\/1027288\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435: \u041f\u043e\u0447\u0435\u043c\u0443 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 Rate Limiting \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0434\u043b\u044f LLM?\u0414\u0435\u043f\u043b\u043e\u0439 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u044f\u0437\u044b\u043a\u043e\u0432\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 (LLM) \u2014 \u044d\u0442\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u043e\u043b\u044c, \u043a\u043e\u0433\u0434\u0430 \u0434\u0435\u043b\u043e \u0434\u043e\u0445\u043e\u0434\u0438\u0442 \u0434\u043e \u043f\u0438\u043a\u043e\u0432\u044b\u0445 \u043d\u0430\u0433\u0440\u0443\u0437\u043e\u043a. \u0412 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0445 web-\u0441\u0435\u0440\u0432\u0438\u0441\u0430\u0445 \u043f\u0440\u0438 \u0432\u044b\u0441\u043e\u043a\u0438\u0445 RPS \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0449\u0438\u043a, \u0430 \u0435\u0441\u043b\u0438 \u0432\u0441\u0451 \u0433\u043e\u0440\u0438\u0442 \u2014 \u0436\u0435\u0441\u0442\u043a\u043e \u0440\u0435\u0436\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u044b HTTP 429 Too Many Requests.\u041d\u043e \u0432 \u043c\u0438\u0440\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0433\u043e AI \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u043e\u0447\u0435\u043d\u044c \u0434\u043e\u0440\u043e\u0433\u043e: \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0443\u0436\u0435 \u043f\u043e\u0434\u043e\u0436\u0434\u0430\u043b, \u043f\u043e\u043a\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u0441\u044f \u0447\u0430\u0442, \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0434\u043b\u0438\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u043c\u043f\u0442, \u043d\u0430\u0436\u0430\u043b Enter \u0438\u2026 \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u043e\u0448\u0438\u0431\u043a\u0443. \u0410 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 GPU-\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043c\u0438\u043d\u0443\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0443 \u043d\u0430\u0441 \u043d\u0435\u0442.\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043f\u043e\u043a\u0430\u0436\u0435\u043c, \u043a\u0430\u043a \u043f\u043e\u0434\u0445\u043e\u0434 \u201c\u0414\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043b\u0435\u043d\u0438\u201d (Dynamic Degradation) \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043f\u0440\u0438 100% \u0443\u0442\u0438\u043b\u0438\u0437\u0430\u0446\u0438\u0438 GPU, \u043d\u0435 \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0430 \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u0441\u0430\u043c\u0443 \u043c\u043e\u0434\u0435\u043b\u044c \u0431\u044b\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u201c\u043a\u0440\u0430\u0442\u043a\u043e\u0439\u201d. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0441\u0432\u043e\u0439 open-source \u0448\u043b\u044e\u0437 LazyGate.\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 LazyGate\u0418\u0434\u0435\u044f \u043f\u0440\u043e\u0441\u0442\u0430: \u043c\u044b \u0441\u0442\u0430\u0432\u0438\u043c \u043f\u0435\u0440\u0435\u0434 \u043d\u0430\u0448\u0438\u043c vLLM \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c \u043b\u0435\u0433\u043a\u043e\u0432\u0435\u0441\u043d\u044b\u0439 ASGI-\u043f\u0440\u043e\u043a\u0441\u0438 \u043d\u0430 \u0431\u0430\u0437\u0435 FastAPI + httpx. \u042d\u0442\u043e\u0442 \u043f\u0440\u043e\u043a\u0441\u0438-\u0448\u043b\u044e\u0437 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043e\u0434\u043d\u0443 \u043a\u043b\u044e\u0447\u0435\u0432\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u2014 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u043e\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u044b NVIDIA (\u0438\u043b\u0438 \u044d\u043c\u0443\u043b\u044f\u0442\u043e\u0440 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438), \u043f\u043e\u043b\u0443\u0447\u0430\u044f \u043c\u0435\u0442\u0440\u0438\u043a\u0443 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0430 GPU.\u041c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u0442\u0440\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430:Normal Load (&lt;75%): \u041e\u0431\u044b\u0447\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c. \u041c\u043e\u0434\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0442\u0438\u0445\u0438, \u0434\u043e\u043b\u0433\u043e \u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0430\u0442\u044c \u0438 \u0432\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0434\u0435\u0442\u0430\u043b\u0438 (max_tokens: 100%).Tired Load (75-90%): \u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0438\u0441\u043f\u044b\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 (\u043e\u0447\u0435\u0440\u0435\u0434\u044c continuous batching \u0440\u0430\u0441\u0442\u0435\u0442). \u041f\u0440\u043e\u043a\u0441\u0438 \u201c\u043d\u0430 \u043b\u0435\u0442\u0443\u201d \u043f\u043e\u0434\u043a\u0438\u0434\u044b\u0432\u0430\u0435\u0442 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 messages \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u043f\u0440\u043e\u043c\u043f\u0442: \u201c\u041e\u0442\u0432\u0435\u0447\u0430\u0439 \u043a\u0440\u0430\u0442\u043a\u043e\u201d, \u0430 max_tokens \u0443\u0440\u0435\u0437\u0430\u0435\u0442\u0441\u044f \u0434\u043e 70%.Extremely Lazy (&gt;90%): \u0410\u0432\u0430\u0440\u0438\u0439\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c. \u0427\u0442\u043e\u0431\u044b \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u043e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u043e\u0447\u0435\u0440\u0435\u0434\u044c KV-\u043a\u044d\u0448\u0430, \u0448\u043b\u044e\u0437 \u0438\u043d\u0436\u0435\u043a\u0442\u0438\u0442 \u0436\u0435\u0441\u0442\u043a\u0438\u0439 \u043f\u0440\u043e\u043c\u043f\u0442: \u201cProvide extremely short answers only. No explanations. Code only if asked.\u201d \u0438 \u0440\u0435\u0436\u0435\u0442 \u0442\u043e\u043a\u0435\u043d\u044b \u0434\u043e 30%.Zero-Blocking \u043f\u043e\u043b\u043b\u0438\u043d\u0433 NVML\u0427\u0438\u0442\u0430\u0442\u044c \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0432\u0438\u0434\u0435\u043e\u043a\u0430\u0440\u0442\u044b \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c HTTP \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0447\u0435\u0440\u0435\u0437 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 Python pynvml \u2014 \u0432\u0435\u0440\u043d\u0430\u044f \u0441\u043c\u0435\u0440\u0442\u044c \u0434\u043b\u044f Event Loop\u2019\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0432\u044b\u043d\u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0432 \u0444\u043e\u043d\u043e\u0432\u0443\u044e asyncio \u0437\u0430\u0434\u0430\u0447\u0443.# \u0418\u0437 \u043d\u0430\u0448\u0435\u0433\u043e hardware.pyasync def _monitor_loop(self):    while True:        # \u0427\u0442\u0435\u043d\u0438\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 (\u043b\u0438\u0431\u043e \u0441\u0438\u043d\u0443\u0441\u043e\u0438\u0434\u044b \u0434\u043b\u044f mock \u0440\u0435\u0436\u0438\u043c\u0430)        new_load = self._fetch_real_load()                # EMA (\u042d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0435 \u0441\u0440\u0435\u0434\u043d\u0435\u0435) \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0431\u043e\u0440\u043e\u0442\u044c &#171;\u0434\u0440\u0435\u0431\u0435\u0437\u0433&#187; \u043d\u0430 \u043f\u043e\u0440\u043e\u0433\u0430\u0445        alpha = 0.3        self._current_load = (new_load * alpha) + (self._current_load * (1 &#8212; alpha))                    await asyncio.sleep(self.update_interval)\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0440\u043e\u0443\u0442\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e  \u0447\u0442\u0435\u043d\u0438\u0435 \u0438\u0437 \u043f\u0430\u043c\u044f\u0442\u0438: monitor.current_load.\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441\u043e \u0441\u0442\u0440\u0438\u043c\u0438\u043d\u0433\u043e\u043c \u0438 SSEvLLM \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0441\u043e \u0441\u0442\u0440\u0438\u043c\u0438\u043d\u0433\u043e\u043c \u0442\u043e\u043a\u0435\u043d\u043e\u0432 (stream=True). \u0415\u0441\u043b\u0438 \u0431\u044b \u043d\u0430\u0448 \u043f\u0440\u043e\u043a\u0441\u0438 \u0431\u0443\u0444\u0435\u0440\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043b \u043e\u0442\u0432\u0435\u0442, \u043c\u044b \u0431\u044b \u0443\u0431\u0438\u043b\u0438 \u0433\u043b\u0430\u0432\u043d\u0443\u044e \u0444\u0438\u0447\u0443 \u2014 Time-to-First-Token (TTFT).\u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u0443\u044e \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0447\u0435\u0440\u0435\u0437 StreamingResponse:# main.pyif is_stream:    async def stream_generator():        async with http_client.stream(&#171;POST&#187;, url, json=body, headers=proxy_headers) as response:            async for chunk in response.aiter_bytes():                yield chunk                    return StreamingResponse(stream_generator(), media_type=&#187;text\/event-stream&#187;)AI \u043a\u0430\u043a \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u0441\u0432\u043e\u0435\u0439 \u0436\u0435 \u201c\u041b\u0435\u043d\u0438\u201d (\u0410\u0432\u0442\u043e\u043d\u043e\u043c\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b)\u041c\u044b \u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u0438 \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c Pytest-\u0442\u0435\u0441\u0442\u044b \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0444\u0438\u043b\u044c \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0432 config.yaml. \u0422\u0430\u043a \u043a\u0430\u043a \u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043c\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c AI-\u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b, \u043c\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0441\u043a\u0440\u0438\u043f\u0442 tester_agent.py.\u042d\u0442\u043e \u201c\u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u0410\u0433\u0435\u043d\u0442\u201d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0430\u043c \u0447\u0438\u0442\u0430\u0435\u0442 \u043a\u043e\u043d\u0444\u0438\u0433 YAML \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u043f\u043e\u0440\u043e\u0433\u043e\u0432, \u0438\u0434\u0435\u0442 \u0432 \u0444\u0430\u0439\u043b \u0441 Pytest-\u0442\u0435\u0441\u0442\u0430\u043c\u0438 \u0447\u0435\u0440\u0435\u0437 Abstract Syntax Trees (AST) \u0438 \u0438\u0449\u0435\u0442, \u043f\u043e\u043a\u0440\u044b\u0442 \u043b\u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 (Normal, Tired, Lazy). \u0415\u0441\u043b\u0438 \u043e\u043d \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u201c\u0434\u044b\u0440\u0443\u201d, \u0441\u043a\u0440\u0438\u043f\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u043a\u043e\u0434 \u043d\u043e\u0432\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430 \u0432 \u0444\u0430\u0439\u043b test_main.py \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440 \u0437\u0430\u043d\u043e\u0432\u043e!\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u043c\u043f\u0442\u0438\u043d\u0433\u0430 \u0434\u043b\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 (LLM Routing) \u2014 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u0435\u0435 \u0433\u0438\u0431\u043a\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434, \u0447\u0435\u043c \u0436\u0435\u0441\u0442\u043a\u0438\u0439 Rate-limiting.\u0412 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0445 \u043f\u043b\u0430\u043d\u0430\u0445 \u2014 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u0448\u043b\u044e\u0437 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u0435 Token Velocity () \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u043f\u0438\u043d\u0433\u0430 NVML, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043d\u0443\u044e \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u043e\u0447\u0435\u0440\u0435\u0434\u0435\u0439 vLLM.\u041a\u043e\u0434 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u0442\u043a\u0440\u044b\u0442 \u043f\u043e\u0434 \u043b\u0438\u0446\u0435\u043d\u0437\u0438\u0435\u0439 \u0434\u043b\u044f \u0430\u043a\u0430\u0434\u0435\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0438 \u043d\u0435\u043a\u043e\u043c\u043c\u0435\u0440\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 \u043d\u0430\u0448\u0435\u043c GitHub. \u041f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0439\u0442\u0435\u0441\u044c!\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 https:\/\/habr.com\/ru\/articles\/1027288\/<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-477187","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/477187","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=477187"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/477187\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=477187"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=477187"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=477187"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}