You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
I Luk Kim 8d1216aa81 fix: 서버 안정성 종합 — BaseHTTPMiddleware 제거 + gc.collect() + Semaphore(5)
반복적인 서버 응답불능의 근본 원인 2가지를 해결:

1. BaseHTTPMiddleware → Pure ASGI 미들웨어 (app/middleware/error_logger.py)
   - BaseHTTPMiddleware.call_next()가 요청당 asyncio task 2개 생성
   - 20 동시연결 × 2 = 40 tasks → event loop scheduler 포화 → health check 타임아웃
   - __call__(scope, receive, send) + send_wrapper 패턴으로 교체
   - 요청당 단일 task, X-Request-ID 헤더 주입, 에러 응답 body 캡처 유지
   - 불필요한 의존성 제거: BaseHTTPMiddleware, Request, Callable, get_db, AsyncSession

2. gc.collect() 추가 + --limit-max-requests 제거 (alpaca.py, docker-compose.yml)
   - --limit-max-requests 500: 500요청 후 단일 worker 종료 → 서비스 gap 발생
   - 대신 intraday 요청 처리 후 gc.collect()로 Python heap 명시적 회수
   - 장시간 백필 중 메모리 누적 방지, worker 재시작 없이 안정 운영

3. Semaphore(3 → 5): BaseHTTPMiddleware 제거로 task 수 절반 → 처리량 복원

유지: mem_limit 2g, --limit-concurrency 20, Phase 4 경량 쿼리, request_logs 7일 retention

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
4 months ago
..
__init__.py Initial commit with full project improvements 5 months ago
alpaca.py fix: 서버 안정성 종합 — BaseHTTPMiddleware 제거 + gc.collect() + Semaphore(5) 4 months ago
attention.py perf: API 성능 개선 Round 2 — 9개 항목 (P6-P14) 5 months ago
catalog.py Initial commit with full project improvements 5 months ago
database.py fix(overlay): 다중 버그 수정 및 OpenAPI 문서 개선 5 months ago
dividends.py feat: PIT dividend calendar + earnings surprise calendar endpoint 4 months ago
earnings.py feat: PIT dividend calendar + earnings surprise calendar endpoint 4 months ago
error_logs.py chore: remove SQLite entirely, PostgreSQL only 5 months ago
etf.py fix(overlay): 다중 버그 수정 및 OpenAPI 문서 개선 5 months ago
filings.py feat: 8-K 재파싱 지원 — force_reparse + 단일 accession 재처리 endpoint 4 months ago
financial.py perf: API 성능 개선 — 로그 분석 기반 6개 항목 수정 5 months ago
finra.py feat: Form 4 내부자 거래 + Earnings Surprise + FINRA 확장 5 months ago
fred.py fix(overlay): 다중 버그 수정 및 OpenAPI 문서 개선 5 months ago
health.py Codebase improvements: caching decorator, Pydantic v2, DB indexes, connection pooling, Alembic 5 months ago
insider.py feat: Earnings Surprise를 SEC XBRL로 전환 + Insider/FINRA 과거 데이터 확장 5 months ago
migration.py Initial commit with full project improvements 5 months ago
news.py fix(overlay): 다중 버그 수정 및 OpenAPI 문서 개선 5 months ago
overlay.py fix(overlay): 다중 버그 수정 및 OpenAPI 문서 개선 5 months ago
price.py fix: GET /price/data — Alpaca → yfinance 교체 + bulk end_date 버그 2건 수정 4 months ago
request_logs.py perf: API 성능 개선 Round 3 — 8개 항목 (P15-P22) 5 months ago
screener.py fix(overlay): 다중 버그 수정 및 OpenAPI 문서 개선 5 months ago
stocks.py docs: 데이터 보유 범위 및 백필 가이드 추가 5 months ago
universe.py fix: isolated thread에 독립적인 DB 엔진 생성 5 months ago