데이터베이스 샤딩
단일 데이터셋을 여러 DB·머신에 분산 저장·처리하는 수평 확장 방식
구조와 동작 원리
화살표를 단계별로 확인하세요.
샤드 키가 데이터 배치와 조회 경로를 결정한다. 교차 샤드 트랜잭션을 고려해야 한다.
기대 효과
여러 머신에 분산해 저장량과 요청 처리량을 수평 확장
트레이드오프
다중 샤드 조회·집계는 네트워크·CPU 오버헤드로 성능 저하
전문성·운영 역량이 부족하거나 작은 규모에는 불필요한 복잡성
운영 및 적용 가이드
종합 설명 · 원문 인용으로 검증된 항목과 구분됩니다. 실제 적용 전 확인이 필요합니다.
언제 사용하는가
대규모 트래픽과 데이터 증가로 단일 DB의 저장·처리 한계를 넘어야 하는 서비스에서 수평 확장, 장애 격리, 지리적 저지연·데이터 주권을 달성할 때 적합하다.
시나리오
글로벌 이커머스 기업이 월 수천만 사용자와 주문 로그를 보유하고, 리전별 주문 조회 지연 50ms 이하와 데이터 주권을 요구한다고 가정하자. 고객 ID 기반 샤드키로 주문 DB를 분할하고 리전별 primary·replica를 배치한다. 샤드별 독립 장애 격리와 선형 확장을 목표로 하며, 크로스샤드 집계는 분석 전용 저장소로 분리한다.
배치 원칙
- 샤드키 선정 후 균등·단조 편향 최소화
- 샤드별 primary와 replica를 서로 다른 장애 도메인·영역에 배치
- 앱과 가까운 리전에 primary 또는 read replica 배치
- 라우팅·메타데이터 카탈로그는 중앙 제어 플레인에, 실제 데이터는 샤드에 분산
- 크로스샤드 조회·집계는 전용 분석 저장소나 비동기 파이프라인으로 우회
온프레미스
전용 서버·로컬 디스크·네트워크를 샤드 단위로 용량 산정하고, 샤드키·리샤딩·백업/복구 절차를 사전 검증한다. 중앙 카탈로그와 라우팅 계층을 이중화하고, 샤드별 모니터링·용량 추세·장애 도메인 분리를 운영 표준으로 둔다.
클라우드
관리형 DB·오토스케일·리전/가용영역 배치를 활용하되 샤드별 비용·IOPS·핫파티션을 모니터링한다. 멀티클라우드·리전 데이터 주권 요구 시 샤드 배치와 복제 방향을 명시하고, 라우팅 계층은 관리형 로드밸런서·서비스 디스커버리로 구성한다.
Kubernetes
샤드 클러스터는 StatefulSet·오퍼레이터·Helm으로 선언적으로 배포하고, 샤드별 PVC·스토리지클래스와 안티어피니티를 설정한다. 멀티클러스터 배치 시 지리·장애 도메인을 분리하고, 오퍼레이터가 리더 선출·스케일·업그레이드를 조정하도록 운영한다.
장애 대응
핫 샤드·샤드 불균형, 크로스샤드 지연, 리샤딩 중단, 복제 지연·페일오버가 대표 장애다. 먼저 영향 샤드와 편향 키를 식별하고, 읽기 분산·핫키 완화·임시 라우팅으로 완화한 뒤 키 재설계·리밸런싱·페일오버/백업 복구를 수행하며 재발 방지 검증을 남긴다.
14개 관점별 근거
조사 당시 근거 보유 여부입니다. 출처의 정확성과 최신성을 별도로 판단하세요.
정의·개요근거 있음
단일 데이터셋을 여러 DB·머신에 분산 저장·처리하는 수평 확장 방식
Sharding is a method for distributing a single dataset across multiple databases, which can then be stored on multiple machines.해결하는 문제근거 있음
단일 서버의 저장 공간·컴퓨팅 자원 한계와 대규모 동시 요청 문제를 완화
A data store on a single server has the following limitations:주요 구성 컴포넌트·리소스근거 있음
샤드는 전용 서버의 로컬 CPU·메모리·플래시·디스크를 가진 독립 DB
Each database is hosted on dedicated server with its own local resources - CPU, memory, flash, or disk.데이터·에셋 배치 원칙근거 있음
동일 컬럼 스키마의 행 부분집합을 샤드에 수평 분할 배치
splitting a database table across shards so that each shard contains the table with the same columns but a different subset of rows.대표 유스케이스근거 있음
선형 확장성, 탄력성, 장애 격리, 지리 분산·데이터 주권이 필요한 앱
applications that require linear scalability, elasticity, fault isolation and geographic distribution of data시나리오 예시근거 있음
지리 샤딩: 특정 샤드 primary를 사용자·앱과 가까운 K8s 클러스터에 배치해 지연 감소
deploying primary nodes of specified shards in different Kubernetes clusters부적합 상황·주의근거 있음
전문성·운영 역량이 부족하거나 작은 규모에는 불필요한 복잡성
Sharding requires significant expertise to implement and manage.온프레미스 관점(개발·배포·운영)근거 있음
온프레미스에서도 전용 하드웨어·소프트웨어 없이 샤드 배포 가능
It requires no specialized hardware or software.클라우드 관점(개발·배포·운영)근거 있음
OCI·Azure·AWS 등 멀티클라우드에 장애 격리 토폴로지로 샤드 배치
deploy the topology across Oracle Cloud, Microsoft Azure, and Amazon Web Services.Kubernetes 관점(개발·배포·운영)근거 있음
멀티 Kubernetes 클러스터에 샤드 클러스터를 분산 배치
You can distribute MongoDB Sharded Clusters over multiple Kubernetes Clusters.장애 대응 관점근거 있음
핫 샤드·편향 키로 인한 쓰기/저장 불균형, 크로스샤드·리샤딩 리스크
Hot shard: the chosen key is monotonic or heavily skewed, so one shard receives disproportionate write load or storage growth.장점근거 있음
여러 머신에 분산해 저장량과 요청 처리량을 수평 확장
by distributing the data across multiple machines, a sharded database can handle more requests than a single machine can.단점·트레이드오프근거 있음
다중 샤드 조회·집계는 네트워크·CPU 오버헤드로 성능 저하
Operations that interact with multiple shards will suffer significant performance penalties as they retrieve results from each member.대표 기술·도구근거 있음
ShardingSphere(Operator/Helm) 등 샤딩 미들웨어·오퍼레이터
ShardingSphere-on-cloud provides ShardingSphere-Operator-Chart and ShardingSphere-Chart추가 참고 문헌 (24)
- Database Sharding: Concepts & Examples | MongoDB ↗
- Sharding Pattern - Azure Architecture Center | Microsoft Learn ↗
- What is Database Sharding? - Shard DB Explained - AWS ↗
- Overview of Oracle Sharding ↗
- Database Infrastructure: Data Sharding, Caching, and Vertical Scaling ↗
- Database Sharding Explained - by Mahdi Yusuf ↗
- Database Sharding ↗
- Database Sharding: Strategies, Benefits, & Best Practices ↗
- docs/sharding/README.md ↗
- Deploy an Oracle Globally Distributed Database on Kubernetes ↗
- Deploy Linearly Scalable Sharded Oracle Databases Distributed Across Oracle Cloud, Microsoft Azure, and Amazon Web Services ↗
- Getting Started with Oracle Globally Distributed Database: Explore the Power of Free Images for Seamless Deployment | database ↗
- Multi-Cluster Sharded Cluster ↗
- Create Your Distributed Database on Kubernetes with Existing Monolithic Databases - InfoQ ↗
- New in MongoDB | MongoDB ↗
- 5 Using Oracle Database Sharding in Oracle Cloud Infrastructure ↗
- Database Sharding | arc42 Quality Model ↗
- Hot Partitions and Partial Failures: Investigating Incidents in Sharded Systems — Decim ↗
- Troubleshoot Sharded Clusters ↗
- The Query Strikes Again | Engineering at Slack ↗
- Masterclass Part 2: Advanced Sharding and Cluster Troubleshooting | MongoDB ↗
- Troubles with Sharding - What can we learn from the Foursquare Incident? - High Scalability - ↗
- Inside Sharding: Partition Maps, Consistent Hashing, Rebalancing, and Hotspots - Pratyush ↗
- Database sharding in Manticore Search: automatic distribution and replication ↗