Skip to content
takeallusernamePublic

About

선착순 쿠폰 발급 시스템, Spring Boot MySQL Redis

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Rush - 선착순 쿠폰 발급 시스템

Spring Boot + MySQL + Redis 기반 선착순 쿠폰 발급 시스템입니다.

기술 스택

Java 17 / Spring Boot 4.0 / MySQL 8.0 / Redis 7 (Lua Script) / Caffeine / Docker Compose

아키텍처

Client
  │
  ▼
┌─────────────────────────────────────────────┐
│  Spring Boot Application                    │
│                                             │
│  ① Local Cache (Caffeine)                   │
│     품절 여부 확인 → 품절이면 즉시 거절       │
│                                             │
│  ② Redis Lua Script                         │
│     재고 확인 + 중복 체크 + 차감 (원자적)     │
│     → 성공 시 큐에 적재 (RPUSH)              │
│                                             │
│  ③ Consumer (JDBC Batch INSERT)             │
│     큐에서 꺼내서 DB에 배치 저장              │
└─────────────────────────────────────────────┘
  │              │              │
  ▼              ▼              ▼
Caffeine       Redis          MySQL
(JVM 메모리)   (인메모리)      (영속 저장소)

프로젝트 구조

src/main/java/com/coupon/rush/
├── config/          RedisConfig — Redis + Lua 스크립트 설정
├── controller/      CouponController — 쿠폰 발급 API
├── entity/          CouponEvent, CouponIssue
├── repository/      JPA Repository + JDBC Batch Repository
└── service/
    ├── CouponService.java         — DB 기반 발급 (비관적 락)
    ├── RedisCouponService.java    — Redis Lua + Local Cache
    └── CouponQueueConsumer.java   — Write-Behind Consumer

src/main/resources/scripts/
└── issue-coupon.lua               — Redis Lua 스크립트

About

선착순 쿠폰 발급 시스템, Spring Boot MySQL Redis

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages