01. Modeling에 대한 정의
- 정의 : Application 의 요구사항과 Database 성능의 균형을 맞추는 ‘공략법’
Embedding vs Referencing
- Embedding : 하나의 Collection에서 모든 Data를 저장함으로써 Read속도가 빠르고,
- 역정규화
- 수정시에 느림(=WRITE)
- Join이 불필요
- 중복이 발생
- Referencing : Join기능, Lookup
- 정규화
- 중복이 발생 X
- 성능이 느림
- 모든 데이터를 읽어야 한다.
- Embedding vs Referencing을 고민할 때
- 데이터의 크기가 얼마나 되는 냐를 따지게 된다.
- MongoDB에서는 16MB가 고정되어있으므로…
- 사전에 얼마나 데이터가 증가할 지를 고민해야된다.
Reducing Resources
- CPU : 연산 자체를 줄이기 보다는 어느 시점에서 CPU연산을 할 지를 정한다.
- Read가 많은 경우 : 미리 연산을 한 다음 Read시에는 적게 하는 방법
- Write가 많은 경우 : 미리 연산을 하지 않고, Read시에 CPU를 이용한 연산을 하여 Write시에는 CPU사용 줄인다.
- 메모리 : Cache사용량에 영향을 준다.
- 항상 Cache에 있어야 하는 데이터 = Working Set
- Working Set을 줄일 수 있을까? >> Disk로 부터 Cache에 적재하는 빈도수를 줄일 수 있을지를 고민