Skip to content

[REFACTOR] 서버 리소스 스펙 최적화#106

Merged
ydking0911 merged 2 commits into
developfrom
refactor/#105/서버-리소스-스펙-최적화
May 9, 2026

Hidden character warning

The head ref may contain hidden characters: "refactor/#105/\uc11c\ubc84-\ub9ac\uc18c\uc2a4-\uc2a4\ud399-\ucd5c\uc801\ud654"
Merged

[REFACTOR] 서버 리소스 스펙 최적화#106
ydking0911 merged 2 commits into
developfrom
refactor/#105/서버-리소스-스펙-최적화

Conversation

@ydking0911
Copy link
Copy Markdown
Member

@ydking0911 ydking0911 commented May 6, 2026

📝 Pull Request Template

📌 제목

서버 리소스 스펙 최적화 (CPU 4→2, RAM 16G→8G)


📢 요약

실제 트래픽 규모 대비 과잉 할당된 서버 리소스를 적정 수준으로 조정

  • CPU 4.0 → 2.0, Memory 16G → 8G

CPU/RAM 다운그레이드에 맞춰 JVM 힙, 커넥션풀, 스레드풀 설정을 일괄 조정

  • JAVA_OPTS 명시: -Xms6g -Xmx6g -XX:+UseG1GC -XX:MaxGCPauseMillis=200 + GC 로그 활성화
  • HikariCP maximum-pool-size 16 → 8, minimum-idle 4 → 2
  • Tomcat max-threads 200 → 100, min-spare-threads 10

🔗 연관 이슈: Resolves #105


🚀 PR 유형

해당하는 항목에 체크해주세요.

  • ✨ 새로운 기능 추가
  • 🐛 버그 수정
  • 🎨 CSS/UI 디자인 변경
  • 🔧 코드에 영향 없는 변경(오타 수정, 탭 사이즈 변경, 변수명 변경 등)
  • 🔨 코드 리팩토링
  • 📝 주석 추가 및 수정
  • 📄 문서 수정
  • 🧪 테스트 추가 또는 리팩토링
  • 🏗️ 빌드 및 패키지 매니저 수정
  • 📂 파일 또는 폴더명 수정
  • 🗑️ 파일 또는 폴더 삭제

✅ PR 체크리스트

PR이 다음 요구 사항을 충족하는지 확인해주세요.

  • 🔹 커밋 메시지 컨벤션을 준수했습니다. (Commit message convention 참고)
  • 🔹 변경 사항에 대한 테스트를 수행했습니다. (버그 수정/기능 테스트)
  • 🔹 관련 문서를 업데이트했습니다. (필요한 경우)

📜 기타

배포 후 애플리케이션 정상 기동 확인 예정
Grafana에서 JVM Heap, GC 횟수, Thread 수 정상 범위 확인 예정
주요 API 응답 시간 p95 이상 없음 확인 예정

Summary by CodeRabbit

  • Chores
    • 백엔드 배포 리소스 한도를 4CPU/16GB에서 2CPU/8GB로 감소했습니다.
    • JVM 힙 크기를 고정(초기/최대 6GB)하고 가비지 컬렉션(G1GC) 관련 설정을 적용했습니다.
    • GC 로그 저장소를 추가하고 로그 회전 설정을 구성했습니다.
    • Tomcat 스레드 풀 설정을 추가했습니다(최대: 100, 최소: 10).
    • 데이터베이스 연결 풀 크기를 조정했습니다(최대: 16→8, 최소: 4→2).

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

운영 서버 스펙 다운그레이드(CPU 4→2, RAM 16G→8G)에 맞춰 런타임 리소스 사용량(JVM/DB 커넥션/서버 스레드)을 낮추기 위한 설정 변경 PR입니다.

Changes:

  • application-prod.yml에서 Tomcat 스레드풀과 HikariCP 커넥션풀 상한을 축소
  • docker-compose.yml에서 backend 서비스의 JVM 옵션(JAVA_OPTS) 추가 및 리소스 제한 값(CPU/메모리) 조정

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/main/resources/application-prod.yml Tomcat thread 및 HikariCP pool 크기 축소로 서버 자원 스펙 하향에 맞춘 설정 조정
docker-compose.yml backend 컨테이너 리소스 제한 값 및 JVM(GC 로깅 포함) 옵션을 추가/조정

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docker-compose.yml Outdated
Comment on lines +59 to +63
deploy:
resources:
limits:
cpus: "4.0"
memory: 16G
cpus: "2.0"
memory: 8G
Comment thread docker-compose.yml Outdated
- PINPOINT_APPLICATION_NAME=dorumdorum
- PINPOINT_AGENT_ID=${PINPOINT_AGENT_ID:-dorumdorum-backend-${HOSTNAME}}
- PINPOINT_AGENT_NAME=${PINPOINT_AGENT_NAME:-dorumdorum-be}
- JAVA_OPTS=-Xms6g -Xmx6g -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -Xlog:gc*:file=/var/log/gc.log:time,uptime,level,tags:filecount=5,filesize=20m
Comment thread docker-compose.yml Outdated
- PINPOINT_APPLICATION_NAME=dorumdorum
- PINPOINT_AGENT_ID=${PINPOINT_AGENT_ID:-dorumdorum-backend-${HOSTNAME}}
- PINPOINT_AGENT_NAME=${PINPOINT_AGENT_NAME:-dorumdorum-be}
- JAVA_OPTS=-Xms6g -Xmx6g -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -Xlog:gc*:file=/var/log/gc.log:time,uptime,level,tags:filecount=5,filesize=20m
Comment thread docker-compose.yml Outdated
- PINPOINT_APPLICATION_NAME=dorumdorum
- PINPOINT_AGENT_ID=${PINPOINT_AGENT_ID:-dorumdorum-backend-${HOSTNAME}}
- PINPOINT_AGENT_NAME=${PINPOINT_AGENT_NAME:-dorumdorum-be}
- JAVA_OPTS=-Xms6g -Xmx6g -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -Xlog:gc*:file=/var/log/gc.log:time,uptime,level,tags:filecount=5,filesize=20m
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 6, 2026

Review Change Stack

Walkthrough

운영 환경에서 컨테이너 리소스(CPU 4→2, 메모리 16G→8G)를 축소하고 JVM 힙(-Xms/-Xmx 6g)과 GC 로깅을 활성화하며, Tomcat 스레드와 HikariCP 풀 크기를 함께 조정합니다.

Changes

서버 리소스 및 스레드풀 최적화

Layer / File(s) Summary
애플리케이션 구성 (Tomcat / HikariCP)
src/main/resources/application-prod.yml
톰캣 스레드풀을 max: 100, min-spare: 10로 추가하고 HikariCP 풀을 maximum-pool-size: 8minimum-idle: 2로 감소시켰습니다.
Docker JVM 환경 및 GC 로그 마운트
docker-compose.yml
backend 서비스에 JAVA_OPTS 환경변수를 추가해 JVM 힙을 -Xms6g -Xmx6g로 고정, G1GC 및 GC 로그(/var/log/gc.log) 설정을 추가하고 /var/log를 컨테이너에 마운트하도록 변경했습니다.
Docker 리소스 제한
docker-compose.yml
backend 서비스의 리소스 설정을 이전 deploy.resources.limits(16G/4.0)에서 mem_limit: 8Gcpus: 2.0으로 조정했습니다.
GC 로그 영속화 볼륨
docker-compose.yml
Compose volumesgc_logs named volume을 추가해 GC 로그를 영속화하도록 했습니다.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • KoungQ
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목은 서버 리소스 스펙 최적화라는 변경사항의 주요 목적을 명확하게 반영하고 있으며, 제시된 모든 코드 변경과 일치합니다.
Linked Issues check ✅ Passed 모든 코드 변경사항이 #105 이슈의 요구사항을 충족합니다: CPU 4→2, RAM 16GB→8GB, JVM 힙 명시, 커넥션풀 및 스레드풀 조정, GC 로깅 활성화.
Out of Scope Changes check ✅ Passed 모든 변경사항이 #105의 서버 리소스 스펙 최적화 범위 내에 있으며, 지정된 파일들(docker-compose.yml, application-prod.yml)에만 제한됩니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/#105/서버-리소스-스펙-최적화

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docker-compose.yml`:
- Line 49: 현재 docker-compose.yml의 JAVA_OPTS 고정 힙 설정(환경변수 JAVA_OPTS, -Xms6g,
-Xmx6g)이 컨테이너 메모리(8GB) 대비 헤드룸이 부족해 OOM 위험이 있으니 -Xmx를 4g로 낮추거나 고정값 대신
-XX:MaxRAMPercentage=<percent>로 변경해 동적으로 힙을 할당하도록 수정하세요; 관련 심볼: JAVA_OPTS, -Xmx,
-Xms, -XX:MaxRAMPercentage를 찾아서 하나의 옵션으로 대체하고 Tomcat 스택/메타스페이스/네이티브 메모리 여유를 고려해
설정값을 적용하세요.
- Line 49: The docker-compose config sets JVM flags via JAVA_OPTS including GC
logging to /var/log/gc.log, but that path is ephemeral inside the container;
update the service's volumes section to mount /var/log/gc.log to the host (or a
named volume) so GC logs persist (e.g., add a volume mapping for
/var/log/gc.log), and if the container memory limit is 8GB reduce the heap
setting in JAVA_OPTS (change -Xmx6g to around -Xmx5.5g) or increase the
container memory limit to avoid OOM kills; ensure you update the same JAVA_OPTS
string and the service's volumes list accordingly.
- Around line 62-63: The deploy.resources.limits (cpus: "2.0", memory: 8G) in
docker-compose.yml is ignored because you run plain docker compose up; update
your deployment script to use docker compose --compatibility up so
deploy.resources.limits are honored, or alternatively change the compose service
to use the legacy container-level keys (mem_limit and cpus) so the runtime
enforces limits; also verify JAVA_OPTS (-Xms6g -Xmx6g) remains consistent with
the container memory limit you choose.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1b7509e1-6744-42a9-8a32-ac40a6361e98

📥 Commits

Reviewing files that changed from the base of the PR and between 2f9eb4e and 58a3b96.

📒 Files selected for processing (2)
  • docker-compose.yml
  • src/main/resources/application-prod.yml

Comment thread docker-compose.yml Outdated
- PINPOINT_APPLICATION_NAME=dorumdorum
- PINPOINT_AGENT_ID=${PINPOINT_AGENT_ID:-dorumdorum-backend-${HOSTNAME}}
- PINPOINT_AGENT_NAME=${PINPOINT_AGENT_NAME:-dorumdorum-be}
- JAVA_OPTS=-Xms6g -Xmx6g -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -Xlog:gc*:file=/var/log/gc.log:time,uptime,level,tags:filecount=5,filesize=20m
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

find . -name "docker-compose.yml" -o -name "docker-compose.yaml" | head -20

Repository: DorumDorum/BE

Length of output: 78


🏁 Script executed:

cat -n ./docker-compose.yml

Repository: DorumDorum/BE

Length of output: 6364


8GB 컨테이너에 6GB 힙 고정 설정은 메모리 헤드룸이 부족할 수 있어요.

Tomcat 스레드들의 스택 메모리, 메타스페이스, 네이티브 메모리, 그리고 Pinpoint 에이전트까지 고려하면 남은 2GB만으로는 부족해서 OOMKilled 위험이 있어요. Xmx를 4GB로 낮춰서 여유 메모리를 더 확보하거나, MaxRAMPercentage 기반으로 동적 설정하는 쪽이 더 안전해요.

권장 수정 예시
-      - JAVA_OPTS=-Xms6g -Xmx6g -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -Xlog:gc*:file=/var/log/gc.log:time,uptime,level,tags:filecount=5,filesize=20m
+      - JAVA_OPTS=-Xms4g -Xmx4g -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -Xlog:gc*:file=/var/log/gc.log:time,uptime,level,tags:filecount=5,filesize=20m
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docker-compose.yml` at line 49, 현재 docker-compose.yml의 JAVA_OPTS 고정 힙 설정(환경변수
JAVA_OPTS, -Xms6g, -Xmx6g)이 컨테이너 메모리(8GB) 대비 헤드룸이 부족해 OOM 위험이 있으니 -Xmx를 4g로 낮추거나
고정값 대신 -XX:MaxRAMPercentage=<percent>로 변경해 동적으로 힙을 할당하도록 수정하세요; 관련 심볼:
JAVA_OPTS, -Xmx, -Xms, -XX:MaxRAMPercentage를 찾아서 하나의 옵션으로 대체하고 Tomcat
스택/메타스페이스/네이티브 메모리 여유를 고려해 설정값을 적용하세요.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# 1) JAVA_OPTS 사용 지점 확인 (Dockerfile/entrypoint/start script)
fd -i 'Dockerfile|entrypoint|start|run' . | xargs -r rg -n -C2 'JAVA_OPTS|JAVA_TOOL_OPTIONS|exec java|java '

# 2) GC 로그 경로 볼륨 매핑 확인
rg -n -C2 '/var/log/gc\.log|volumes:' docker-compose.yml

# 3) 실행 후 실제 JVM 플래그 반영 확인 (운영/로컬에서)
# docker compose up -d backend
# docker exec -it ${CONTAINER_NAME:-dorumdorum-be} sh -lc 'ps -ef | rg "java|Xms|Xmx|Xlog"'

Repository: DorumDorum/BE

Length of output: 2458


🏁 Script executed:

sed -n '45,70p' docker-compose.yml | cat -n

Repository: DorumDorum/BE

Length of output: 1109


GC 로그 파일 볼륨 마운트를 추가해야 합니다.

현재 설정에서 JAVA_OPTS는 Dockerfile의 ENTRYPOINT에서 ${JAVA_OPTS}로 올바르게 확장되므로 JVM 플래그들이 제대로 적용됩니다. 다만 /var/log/gc.log 경로는 컨테이너의 임시 파일시스템이기 때문에 컨테이너 재시작 시 로그가 모두 삭제됩니다. 디버깅과 성능 분석을 위해 GC 로그를 보존하려면 다음과 같이 수정해주세요:

volumes:
  - ./firebase-service-account.json:/app/firebase-service-account.json:ro
  - /var/log/gc.log:/var/log/gc.log  # 또는 named volume 사용

또한 6GB 힙을 8GB 메모리 제한에 할당한 경우, 약 2GB 만이 JVM 네이티브 메모리(스레드, 메타스페이스, 직접 버퍼), Pinpoint 에이전트 오버헤드, 커널 버퍼 등으로 남습니다. 운영 환경에서 OOMKill이 발생하면 힙 크기를 5.5GB 정도로 조정하거나 메모리 제한을 증가시켜주세요.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docker-compose.yml` at line 49, The docker-compose config sets JVM flags via
JAVA_OPTS including GC logging to /var/log/gc.log, but that path is ephemeral
inside the container; update the service's volumes section to mount
/var/log/gc.log to the host (or a named volume) so GC logs persist (e.g., add a
volume mapping for /var/log/gc.log), and if the container memory limit is 8GB
reduce the heap setting in JAVA_OPTS (change -Xmx6g to around -Xmx5.5g) or
increase the container memory limit to avoid OOM kills; ensure you update the
same JAVA_OPTS string and the service's volumes list accordingly.

Comment thread docker-compose.yml Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
docker-compose.yml (1)

49-49: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

-Xms6g -Xmx6g는 8G 컨테이너 한도 대비 메모리 헤드룸이 부족합니다.

Line 49 설정은 힙 외 메모리(메타스페이스, 스레드 스택, direct buffer, 에이전트 오버헤드) 여유가 작아서 OOMKilled 위험이 있습니다. 힙 상한을 더 낮추시거나 비율 기반으로 전환해 주세요.

권장 수정 예시
-      - JAVA_OPTS=-Xms6g -Xmx6g -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -Xlog:gc\*:file=/var/log/gc.log:time,uptime,level,tags:filecount=5,filesize=20m
+      - JAVA_OPTS=-Xms4g -Xmx4g -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -Xlog:gc\*:file=/var/log/gc.log:time,uptime,level,tags:filecount=5,filesize=20m
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docker-compose.yml` at line 49, The JAVA_OPTS environment setting currently
hard-sets heap to -Xms6g -Xmx6g which leaves insufficient headroom for
metaspace, thread stacks and native buffers and risks OOMKilled; update the
JAVA_OPTS entry to either lower the fixed heap (e.g., set -Xmx4g and remove or
reduce -Xms) or switch to ratio-based settings like removing -Xms/-Xmx and
adding -XX:InitialRAMPercentage=50 -XX:MaxRAMPercentage=75 (or other percentages
appropriate for an 8G container) so the JVM uses a safe portion of container
RAM; modify the JAVA_OPTS value accordingly in the docker-compose env line.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@docker-compose.yml`:
- Line 49: The JAVA_OPTS environment setting currently hard-sets heap to -Xms6g
-Xmx6g which leaves insufficient headroom for metaspace, thread stacks and
native buffers and risks OOMKilled; update the JAVA_OPTS entry to either lower
the fixed heap (e.g., set -Xmx4g and remove or reduce -Xms) or switch to
ratio-based settings like removing -Xms/-Xmx and adding
-XX:InitialRAMPercentage=50 -XX:MaxRAMPercentage=75 (or other percentages
appropriate for an 8G container) so the JVM uses a safe portion of container
RAM; modify the JAVA_OPTS value accordingly in the docker-compose env line.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: ASSERTIVE

Plan: Pro

Run ID: bea86c3c-0deb-4356-abea-2e37251b652f

📥 Commits

Reviewing files that changed from the base of the PR and between 58a3b96 and 76cbd5c.

📒 Files selected for processing (1)
  • docker-compose.yml

Copy link
Copy Markdown
Member

@KoungQ KoungQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ydking0911 ydking0911 merged commit 9e0d81d into develop May 9, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants