Skip to content
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

[#249] 크루 랭킹의 캐시 저장소 변경, 캐싱 스케줄러의 중복 실행 방지 #266

Merged
merged 2 commits into from
Dec 7, 2023

Conversation

charlesuu
Copy link
Collaborator

@charlesuu charlesuu commented Dec 3, 2023

관련 PR 목록

1. 크루 랭킹 기능
2. 랭킹에 로컬 캐시 적용
3. 크루 랭킹의 캐시 저장소 변경, 캐싱 스케줄러의 중복 실행 방지

👨‍💻 작업 사항

📑 PR 개요

  • 스케일 아웃 환경에서 캐시의 정합성을 맞추기 위해 크루 랭킹의 캐시 저장소를 CaffeineCache에서 Redis로 변경
    (로컬 -> 글로벌)
  • Redis분산락을 이용하여 스케일 아웃 환경에서 캐싱 스케줄러의 중복 실행 방지

✅ 작업 목록

  • 스케일 아웃 환경에서 캐시의 정합성을 맞추기 위해 크루 랭킹의 캐시 저장소를 로컬에서 글로벌로 변경(CaffeineCache -> Redis)
  • 분산락을 이용하여 스케일 아웃 환경에서 캐싱 스케줄러의 중복 실행 방지 기능 구현

🙏 리뷰어에게

캐시 저장소 변경 이유(로컬 -> 글로벌)

  • 스케일 아웃 된 운영 환경에서 로컬 캐시의 정합성이 안 맞는 경우가 생길 수 있습니다.
    • 캐시의 갱신 작업이 일어날 때, 테이블 변경이 생겨서 찰나의 순간에 두 서버가 같은 쿼리를 통해 다른 결과를 받아온 경우.
    • 모종의 이유로 한 서버의 스케줄러가 작동하지 않아서 둘 중 하나의 서버만 캐시를 갱신한 경우 등.
  • 크루 랭킹은 추후 경쟁 시스템과 연관이 생길 수 있어 도메인적으로 예민한 데이터이고, 메인 페이지에 표기되는 기능이기에 캐시 정합성이 좀 더 엄격하게 맞춰지면 좋겠다고 생각했습니다.

📀 관련 데이터 (화면, 테이블, API 등)

화면

image

테이블 명

  • crew, member, game, crew_member, game_member

API endpoint

  • GET /ranking/crews

반환 예시

200 OK

[
  {
    "id": 14,
    "name": "노드크루",
    "memberCount": 10,
    "maxMemberCount": 15,
    "profileImageUrl": "pickpleCrewProfileImage.s3.ap-northeast-2.amazonaws.com",
    "addressDepth1": "서울시",
    "addressDepth2": "강남구",
    "crewActivityScore": 10000,
    "mannerScore": 10000,
    "totalScore": 20000,
    "rank": 1,
  },
  {
    "id": 9,
    "name": "하하크루",
    "memberCount": 3,
    "maxMemberCount": 10,
    "profileImageUrl": "pickpleCrewProfileImage.s3.ap-northeast-2.amazonaws.com",
    "addressDepth1": "서울시",
    "addressDepth2": "마포구",
    "crewActivityScore": 10000,
    "mannerScore": 5000,
    "totalScore": 15000,
    "rank": 2,
  },
  {
    "id": 142,
    "name": "룰루크루",
    "memberCount": 20,
    "maxMemberCount": 25,
    "profileImageUrl": "pickpleCrewProfileImage.s3.ap-northeast-2.amazonaws.com",
    "addressDepth1": "서울시",
    "addressDepth2": "동대문구",
    "crewActivityScore": 1000,
    "mannerScore": 5000,
    "totalScore": 6000,
    "rank": 3,
  },
  ...	
]

Prefix

PR 코멘트를 작성할 때 항상 Prefix를 붙여주세요.

  • P1: 꼭 반영해주세요 (Request changes)
  • P2: 적극적으로 고려해주세요 (Request changes)
  • P3: 웬만하면 반영해 주세요 (Comment)
  • P4: 반영해도 좋고 넘어가도 좋습니다 (Approve)
  • P5: 그냥 사소한 의견입니다 (Approve)

@charlesuu charlesuu added the 신규 기능 [feat] 새로운 기능을 추가한다. label Dec 3, 2023
@charlesuu charlesuu added this to the 6차 스프린트 milestone Dec 3, 2023
@charlesuu charlesuu self-assigned this Dec 3, 2023
Copy link

sonarqubecloud bot commented Dec 3, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

72.7% 72.7% Coverage
0.0% 0.0% Duplication

@charlesuu charlesuu linked an issue Dec 4, 2023 that may be closed by this pull request
1 task
@charlesuu charlesuu merged commit b5f0bb1 into dev Dec 7, 2023
3 checks passed
@charlesuu charlesuu deleted the feature/#249 branch December 7, 2023 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
신규 기능 [feat] 새로운 기능을 추가한다.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[랭킹] 랭킹에 글로벌 캐시 적용
4 participants