Skip to content

[기능] 음식 상품 재고 스케줄링 업데이트#158

Open
kimhyun5u wants to merge 2 commits intomainfrom
feature/157_kimhyun5u_음식-상품-재고-스케줄링-업데이트

Hidden character warning

The head ref may contain hidden characters: "feature/157_kimhyun5u_\uc74c\uc2dd-\uc0c1\ud488-\uc7ac\uace0-\uc2a4\ucf00\uc904\ub9c1-\uc5c5\ub370\uc774\ud2b8"
Open

[기능] 음식 상품 재고 스케줄링 업데이트#158
kimhyun5u wants to merge 2 commits intomainfrom
feature/157_kimhyun5u_음식-상품-재고-스케줄링-업데이트

Conversation

@kimhyun5u
Copy link
Member

@kimhyun5u kimhyun5u commented Sep 19, 2024

💡 다음 이슈를 해결했어요.

Issue Link


💡 이슈를 처리하면서 추가된 코드가 있어요.

  • MenuStockUpdateScheduleService.java
    // 5초마다 메뉴 재고를 RDB에 동기화
    @Scheduled(fixedRate = 1000 * 5)
    @Transactional
    public void syncMenuStockToRDB() {
    // redis 에서 메뉴 정보 조회
    Map<String, Long> menuStockMap = new HashMap<>();
    redissonClient.getKeys().getKeysStreamByPattern(RedisCacheConstants.MENU_STOCK_PREFIX + "*")
    .forEach(key -> {
    // 메뉴 정보 조회
    String menuId = key.split(":")[1];
    // 메뉴 재고 조회
    Long stock = redissonClient.getAtomicLong(key).get();
    menuStockMap.put(menuId, stock);
    });
    // 메뉴 재고를 RDB에 동기화
    updateMenuStockDao.updateMultipleMenuStocks(menuStockMap);
    }

💡 다음 자료를 참고하면 좋아요.

비관락

Type Name # Requests # Fails Average (ms) Min (ms) Max (ms) Average size (bytes) RPS Failures/s
POST /orders 13486 0 17538.89 74 50876 38.18 30.92 0

재고 캐싱

Type Name # Requests # Fails Average (ms) Min (ms) Max (ms) Average size (bytes) RPS Failures/s
POST /orders 26718 0 8715.08 479 18227 39 48.95 0

✅ 셀프 체크리스트

  • 내 코드를 스스로 검토했습니다.
  • 필요한 테스트를 추가했습니다.
  • 모든 테스트를 통과합니다.
  • 브랜치 전략에 맞는 브랜치에 PR을 올리고 있습니다.
  • 커밋 메세지를 컨벤션에 맞추었습니다.
  • wiki를 수정했습니다.

- 5분 간격으로 DB 싱크 기준 설정(추후 트래픽에 따른 동적 변경 적용)
- 주문과 동시에 RDB 검증 주석 처리
@kimhyun5u kimhyun5u added the 💪 Improve 기능 고도화 & 개선 label Sep 19, 2024
@kimhyun5u kimhyun5u added this to the 리팩토링 milestone Sep 19, 2024
@kimhyun5u kimhyun5u self-assigned this Sep 19, 2024
@kimhyun5u kimhyun5u linked an issue Sep 19, 2024 that may be closed by this pull request
@kimhyun5u kimhyun5u marked this pull request as ready for review September 19, 2024 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💪 Improve 기능 고도화 & 개선

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[기능] 음식 상품 재고 스케줄링 업데이트

1 participant