Giter Site home page Giter Site logo

gwangya-ticket's Introduction

gwangya-ticket

티켓 예매 서비스

gwangya-ticket's People

Contributors

f-lab-bot avatar f-lab-dev avatar soheelee408 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

gwangya-ticket's Issues

프로젝트 초기 세팅

  • Spring & Java 버전 결정

  • 프로젝트 생성 & 의존성 설정

  • ERD
    gwangya-erd-5

  • Data Flow
    gwangya-DFD_

  1. 로그인 한다.
  2. 특정 공연을 조회한다.
  3. 관람 회차를 선택한다.
  4. 예매 상태를 포함하여 모든 좌석을 조회한다.
  5. 좌석을 선택한다.
  6. 결제 수단을 선택한다.
  7. 예매 한다.
  • 패키지 구조 설정
┌gwangya
├─global
│  ├─advice
│  ├─base
│  ├─config
│  └─util
└─user
    ├─controller
    ├─domain
    │  └─vo
    ├─repository
    ├─service
    └─dto

공연 조회 API 구현

  • 오늘 자 기준 오픈 된 공연, 오픈 예정인 공연 목록을 볼 수 있다.
  • 로그인 없이 조회 가능하다.
  • 목록에 표시된 공연은 모두 상세 조회 가능하다.

좌석 선택 기능 구현

요구 사항

  • 예매 기간이 아닌 경우 좌석을 선택할 수 없다.
  • 예매 가능 매수를 초과한 경우 좌석을 선택할 수 없다.
  • 1~최대 가능 매수(공연마다 다름)개의 좌석을 선택할 수 있다.
  • 요청된 좌석이 모두 선택되거나 실패한다.
  • 좌석은 중복 선택될 수 없다.

TO DO

  • 요구 사항 구현
  • 단위 테스트 작성
  • 통합 테스트 작성
  • Hazelcast 서버 세팅

동시성 이슈 해결

✔️ 추후 링크 첨부 예정

처리 방법 비교

  • Optimistic Lock/Pessimistic Lock/Named Lock/Distribution Lock

분산 락 기술 비교

  • Redisson/Zookeeper/Hazelcast

분산 락을 적용한 좌석 선택 기능 구현

테스트

단위 테스트

  • n개이 좌석을 점유할 수 있다.
  • 요청된 좌석이 모두 선택되거나 실패한다.(선택한 좌석의 일부만 점유할 수 없다.)
  • 중복 요청은 한 번만 반영된다.
  • 이미 lock이 걸린 경우 예외가 발생한다.
  • 다른 유저가 점유한 좌석인 경우 예외가 발생한다.
    image

통합 테스트

  • 동일한 좌석을 순차적으로 선택했을 때 늦게 들어온 요청은 좌석을 점유할 수 없다.
  • 다른 요청에서 점유한 좌석일 경우 예외가 발생한다.
  • 점유 되지 않은 좌석은 점유할 수 있다.
  • 요청 수가 100일 때 선택된 좌석의 무결성이 보장된다.
  • 요청 수가 10,000일 때 선택된 좌석의 무결성이 보장된다.
  • 요청 수가 100,000일 때 선택된 좌석의 무결성이 보장된다.
    image

트러블 슈팅

  • 10만 건 이상의 요청에 대한 처리 시간 단축

    🖊️ 1h → 3m 15s 로 줄이기는 했으나 더 줄여야 할 것 같다.

  • 테스트 검증 로직 처리 시간 단축

    ➡️ 분산 데이터 저장소(Hazelcast의 IMap)에서 빈번한 데이터 조회로 인한 시간 지연 이슈

  • 통합 테스트 전체 실행 시, 특정 항목에서 지연 발생(단독 실행 시에는 문제없음)

    ➡️ 이전 테스트에 저장된 Lock으로 인함 → 개별 테스트 종료마다 Lock 해제 로직 추가

회원 가입 구현

  • 요구 사항 정리

  • 이메일은 필수이다.

  • 이메일은 이메일 형식을 만족해야 한다.

  • 중복된 이메일은 사용할 수 없다.

  • 비밀번호는 필수이다.

  • 비밀번호는 알파벳 대소문자, 숫자, 특수 문자를 포함하여 8~20자리여야 한다.

  • 비밀번호는 암호화하여 저장되어야 한다.

  • 테스트 구현

  • 프로덕션 코드 구현

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.