Measure scaling cost and confirm two-replica operating point
This commit is contained in:
+9
-2
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user