refactor: Row Lock 경합 제거를 위한 레슨 참가자 수 업데이트 로직 디커플링#222
Merged
Ji-minhyeok merged 1 commit intoApr 23, 2026
Conversation
Ji-minhyeok
added a commit
that referenced
this pull request
Apr 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 배경 및 문제점
현상
현재 컨슈머 로직에서 각 메시지(또는 배치) 처리 시 Lesson 테이블의
participantCount를 실시간으로 업데이트함원인
단일 lessonId에 대한 부하 집중 시 DB의 Row Lock 경합으로 인해 컨슈머를 Scale-out해도 처리량이 선형적으로 증가하지 않는 병목 발생
지표
iostat 확인 결과 디스크 I/O 유틸리티는 낮으나(%util 30% 미만) DB CPU 사용량이 높고 락 대기 시간으로 인해 전체 레이턴시가 증가함
🚀 개선 목표
🛠 작업 내용
1. 메시지 소비 로직 수정
Participant엔티티의INSERT작업만 수행 (Row Lock 경합 없음)Lesson엔티티에 대한 직접적인UPDATE또는 Dirty Checking 호출 제거2. 최종 보정 로직 구현
Lesson.participantCount를 업데이트COUNT(*)쿼리를 기반으로 한 원자적(Atomic) 업데이트 쿼리 적용✅ PR 유형
✅ Check List
🔗 관련 이슈
💬 기타 참고 사항