base: 35 RPS; safety, 75 RPS

# What does this PR do?


## Test Plan
# What does this PR do?


## Test Plan
This commit is contained in:
Eric Huang 2025-09-02 14:00:23 -07:00
parent faf891b40c
commit c3fa3e6333
5 changed files with 41 additions and 4 deletions

View file

@ -525,9 +525,8 @@ class InferenceRouter(Inference):
response = await self._nonstream_openai_chat_completion(provider, params)
# Store the response with the ID that will be returned to the client
if self.store:
await self.store.store_chat_completion(response, messages)
asyncio.create_task(self.store.store_chat_completion(response, messages))
if self.telemetry:
metrics = self._construct_metrics(
@ -855,4 +854,4 @@ class InferenceRouter(Inference):
object="chat.completion",
)
logger.debug(f"InferenceRouter.completion_response: {final_response}")
await self.store.store_chat_completion(final_response, messages)
asyncio.create_task(self.store.store_chat_completion(final_response, messages))

View file

@ -73,6 +73,7 @@ from llama_stack.providers.inline.telemetry.meta_reference.telemetry import (
TelemetryAdapter,
)
from llama_stack.providers.utils.telemetry.tracing import (
BACKGROUND_LOGGER,
CURRENT_TRACE_CONTEXT,
end_trace,
setup_logger,
@ -204,6 +205,10 @@ async def sse_generator(event_gen_coroutine):
async def log_request_pre_validation(request: Request):
# Skip expensive body parsing if debug logging is disabled
if not logger.isEnabledFor(logging.DEBUG):
return
if request.method in ("POST", "PUT", "PATCH"):
try:
body_bytes = await request.body()
@ -305,6 +310,10 @@ class TracingMiddleware:
logger.debug(f"Bypassing custom routing for FastAPI built-in path: {path}")
return await self.app(scope, receive, send)
# Quick exit if telemetry is disabled - skip expensive route matching and tracing
if BACKGROUND_LOGGER is None:
return await self.app(scope, receive, send)
if not hasattr(self, "route_impls"):
self.route_impls = initialize_route_impls(self.impls, self.external_apis)

View file

@ -362,7 +362,9 @@ class VLLMInferenceAdapter(Inference, ModelsProtocolPrivate):
return AsyncOpenAI(
base_url=self.config.url,
api_key=self.config.api_token,
http_client=httpx.AsyncClient(verify=self.config.tls_verify),
http_client=httpx.AsyncClient(
verify=self.config.tls_verify, limits=httpx.Limits(max_connections=1000, max_keepalive_connections=1000)
),
)
async def completion(