Measure scaling cost and confirm two-replica operating point

This commit is contained in:
Самохвалов Андрей Ремович
2026-10-02 13:59:18 +03:00
parent 23ed63f593
commit 750e56d0c6
13 changed files with 739 additions and 5 deletions
+9 -2
View File
@@ -6,6 +6,7 @@ from uuid import UUID
from fastapi import APIRouter, Depends, HTTPException, Query, Request, Response
from .auth import basic_credentials, bearer_token
from . import db
from .models import CreateChat, CreateMessage, CreateUser
from .store import store
@@ -18,8 +19,14 @@ def live():
@router.get("/health/ready")
def ready():
return store.ready()
def ready(response: Response):
result = store.ready()
stats = db.pool().get_stats()
for header, key in (("X-Pool-Requests", "requests_num"), ("X-Pool-Queued", "requests_queued"),
("X-Pool-Wait-Ms", "requests_wait_ms"), ("X-Pool-Size", "pool_size"),
("X-Pool-Available", "pool_available")):
response.headers[header] = str(stats.get(key, 0))
return result
@router.post("/api/v1/users", status_code=201)