-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: 좋아요 기능 구현 #87
Merged
Merged
feat: 좋아요 기능 구현 #87
Conversation
This file contains 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
1a18c10
to
46a3cee
Compare
sukjuhong
reviewed
Jan 9, 2025
pofo-api/src/main/kotlin/org/pofo/api/domain/like/LikeController.kt
Outdated
Show resolved
Hide resolved
sukjuhong
approved these changes
Jan 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
낙관적 락은 적절한 적용인거 같습니다!
LGTM!
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.
Overview
좋아요 기능 구현
Related Issue
Issue Number : resolve #79
Task Details
프로젝트에 좋아요 기능을 추가했습니다.
likes 테이블을 따로 만들어서 좋아요 여부를 기록해둡니다.
또한, 페이지네이션에서 좋아요 개수가 표시될텐데, 매번 like 테이블에서 Count 집계 쿼리를 날려 조회하면 성능적 결함이 발생하므로 따로 Project에 좋아요 개수를 기록하는 칼럼을 만들어서 여기에서 받아오도록 처리했습니다.
이때, 이 부분은 동시성 문제가 발생하기 좋은 부분이라고 생각했습니다. 그런데 이를 비관적락, Redis 분산락 등의 방법으로 처리하면 너무 성능적으로 좋지 않습니다. (동시성이 발생하긴 하지만, 자주 발생하는 부분은 아니기 때문이라고 생각했습니다)
따라서, 낙관적락을 도입해서 Version 충돌시에만 다시 시도하도록 구성한 것입니다. 이에 따른 retry 로직도 작성했습니다. 5번 retry해서 실패하면 그냥 좋아요 실패했다고 오류를 띄워줍니다. (Errorcode like-003)
이에 따른 테스트 코드 작성도 했습니다. 스레드들이 동시에 좋아요를 증가시켜 테스트하는 방식입니다.
============= 추가=============
낙관적락 재시도가 정상적으로 작동하지 않아 Spring에서 제공하는 Retryable 라이브러리를 활용하도록 수정했습니다. 재시도 횟수는 10회이며, 지수 백오프 전략으로 대기 시작이 증가하도록 구성했습니다. 10회 실패시 그냥 좋아요가 실패합니다.
Review Requirements
프로젝트 목록에서 바로 좋아요 할 수 있게 할 것인지, 또한 프로젝트 목록에서 자신의 좋아요 여부를 표시해야되는지 고민해볼 필요가 있습니다.
제가 감기에 걸려서 어제 하루종일 누워 있었고, 담주 홍콩으로 해외 출장 또 가는데 이에 관해서 일정 짜기 및 항공권/교통/숙소 등 예약을 제가 담당하게 되어 처리할게 많아 너무 바빠가지고 개발 속도가 느린점 정말 죄송하게 생각합니다... 최대한 열심히 해보겠습니다.