Skip to content

MySQL Read Replica 라우팅 (LazyConnectionDataSourceProxy)#123

Merged
chooh1010 merged 2 commits into
mainfrom
feat/db-replica
May 16, 2026
Merged

MySQL Read Replica 라우팅 (LazyConnectionDataSourceProxy)#123
chooh1010 merged 2 commits into
mainfrom
feat/db-replica

Conversation

@chooh1010

@chooh1010 chooh1010 commented May 16, 2026

Copy link
Copy Markdown
Member

Summary

  • DataSourceConfig에서 write/read DataSource를 분리하고 LazyConnectionDataSourceProxy로 자동 라우팅
  • @Transactional(readOnly=true) → Replica, 그 외 → Master로 연결
  • Spring 6.1.2+ 네이티브 기능 활용, 별도 라이브러리 불필요

변경 사항

  • src/main/java/com/example/popping/config/db/DataSourceConfig.java (신규)

Test plan

  • 앱 기동 후 게시글 조회(readOnly) 시 Replica로 쿼리 확인 (general_log)
  • 게시글 작성(write) 시 Master로 쿼리 확인
  • 1000 vuser 부하테스트 Before/After 비교

Closes #122

🤖 Generated with Claude Code

…Proxy

Introduce dual DataSource configuration that automatically routes
@transactional(readOnly=true) queries to a read replica using
Spring 6.1.2+ LazyConnectionDataSourceProxy.setReadOnlyDataSource()

Closes #122

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@chooh1010 chooh1010 linked an issue May 16, 2026 that may be closed by this pull request
4 tasks
@chooh1010 chooh1010 changed the title feat: MySQL Read Replica 라우팅 (LazyConnectionDataSourceProxy) MySQL Read Replica 라우팅 (LazyConnectionDataSourceProxy) May 16, 2026
@chooh1010 chooh1010 self-assigned this May 16, 2026
@chooh1010 chooh1010 added the feat add new features label May 16, 2026
Skip dual DataSource setup when property is absent (CI/EC2 single MySQL),
falling back to Spring Boot auto-configuration with spring.datasource.*

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@chooh1010 chooh1010 merged commit 1e11324 into main May 16, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat add new features

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

MySQL Read Replica 분리를 통한 DB 부하 분산

1 participant