From 253086eaad719ef99927c7fdb677b5c5c1ef4767 Mon Sep 17 00:00:00 2001 From: I Luk Kim Date: Wed, 15 Apr 2026 01:02:28 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20Python=20heap=20=EB=88=84=EC=A0=81=20OOM?= =?UTF-8?q?=20=EB=B0=A9=EC=A7=80=20=E2=80=94=20max-requests=20500=20+=20?= =?UTF-8?q?=EC=BB=A8=ED=85=8C=EC=9D=B4=EB=84=88=20=EB=A9=94=EB=AA=A8?= =?UTF-8?q?=EB=A6=AC=202GB=20=EC=A0=9C=ED=95=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Python CPython 메모리 할당자는 freed 블록을 OS에 반환하지 않음. 수백 건의 백필 요청 처리 후 heap이 계속 성장 → 시스템 전체 OOM. 변경: - --limit-max-requests 500: 500요청 후 uvicorn worker 자동 재시작 → heap 초기화, 메모리 누수 방지 - mem_limit/memswap_limit 2g: 컨테이너 메모리 2GB 하드 캡 → OS 전체가 아닌 컨테이너 안에서 OOM 제어 → Docker restart: unless-stopped로 자동 복구 Co-Authored-By: Claude Sonnet 4.6 --- docker-compose.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 626ca19..013d4b3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -65,8 +65,10 @@ services: - ./API_DOCUMENTATION.md:/app/API_DOCUMENTATION.md # API documentation - ./yfinance_plus:/app/yfinance_plus # Mount yfinance_plus for development - ./data:/app/data # For data files + mem_limit: 2g + memswap_limit: 2g restart: unless-stopped - command: ["python", "-m", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "18000", "--reload", "--limit-concurrency", "20"] + command: ["python", "-m", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "18000", "--reload", "--limit-concurrency", "20", "--limit-max-requests", "500"] # Frontend Application frontend: