feat: MLX /status API 통합 — GPU 무접촉 부하 측정

- model_adapter.status_check(): GET /status, 미지원 백엔드는 None
- backend_registry.get_load_status(): /status API 1순위, hybrid fallback
  - active_jobs >=4 매우 바쁨, >=2 바쁨, =1 보통, =0 여유
  - source: status_api | hybrid 표시
- worker._build_system_status(): source별 분기, active_jobs/total_requests 표시
- hybrid 경로의 self-job 제외 (active > 1)
- health loop에서 status도 같이 캐시 (지원 백엔드만)

Mac mini /opt/mlx-proxy.py에 active_jobs 카운터 + /status 엔드포인트 추가됨

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Hyungi Ahn
2026-04-07 08:06:44 +09:00
parent 3eacbac964
commit cc792eddbb
3 changed files with 80 additions and 16 deletions

View File

@@ -100,19 +100,26 @@ async def _build_system_status(force_measure: bool = True) -> str:
load = await backend_registry.get_load_status(role, force_measure=force_measure)
connected = "정상" if info["healthy"] else "연결 안 됨"
load_str = load["load"]
baseline = load["health_baseline_ms"]
ratio = (load["health_ms"] / baseline) if baseline > 0 else 1.0
source = load.get("source", "hybrid")
line1 = f"{info['name']}: {connected}{load_str}"
line2 = f" health {load['health_ms']:.0f}ms (baseline {baseline:.0f}ms, {ratio:.1f}배)"
if load["measured"]:
line3 = f" ping {load['inference_ms']:.0f}ms"
else:
line3 = " ping: 측정 안 함"
lines.append(line1)
lines.append(line2)
lines.append(line3)
if source == "status_api":
# /status API 직접 조회 — 정확한 active_jobs
active = load.get("active_jobs", 0)
total = load.get("total_requests", 0)
lines.append(f" active_jobs: {active} (total: {total}) [status API]")
lines.append(f" health {load['health_ms']:.0f}ms")
else:
# hybrid fallback (health baseline + 조건부 ping)
baseline = load["health_baseline_ms"]
ratio = (load["health_ms"] / baseline) if baseline > 0 else 1.0
lines.append(f" health {load['health_ms']:.0f}ms (baseline {baseline:.0f}ms, {ratio:.1f}배)")
if load["measured"]:
lines.append(f" ping {load['inference_ms']:.0f}ms")
else:
lines.append(" ping: 측정 안 함")
lines.append("")
queue = jq_module.job_queue.stats if jq_module.job_queue else {"pending": 0, "active": 0}