2. index
1. Desirable Properties of a Web App
2. Reference Architecture
1. Flickr Architecture
2. LiveJournal Architecture
3. Facebook Architecture
3. Build Scalable Architecture Process
1. Step 1 - One Server
2. Step 2 - One Server - Vertical Scaling
3. Step 3 - Two Server - Vertical Partitioning (Services)
4. Step 4 - Horizontal Scaling (App Server)
5. Step 5 - Vertical Partitioning (Hardware)
6. Step 6 - Horizontal Scaling (DB Scaling)
7. Step 7 - Vertical / Horizontal Partitioning (DB)
8. Step 8 - Seperating Sets (Federation)
4. 엠넷은?
2
3. Desirable Properties of a Web App
•확장성(Scalability)
•고가용성(High Availability)
•성능(Performance)
•응답성(Responsiveness)
•관리성(Manageability)
•저비용(Low Cost)
3
4. High Availability
고가용성(HA)이란 바람직한 정도로 긴 시간동안 지속적으로 운영이 가
능한 시스템이나 컴포넌트를 가리킨다.
가용성이란 흔히 "100% 가용" 등과 같이 상대적으로 측정되거나 또는 "
절대 고장나지 않음" 등과 같이 표현될 수 있다.
널리 쓰이고 있지만 달성하기 결코 쉽지 않은 시스템 및 제품에 대한 가
용성 표준에 흔히 “파이브 나인(five 9)이라고 부르는 99.999%의 가용성
을 들 수 있다.
4
5. Architecture
아키텍처란, 프로세스와 전체적인 구조나 논리적 요소들 그리고 컴퓨터
와 운영체계, 네트웍 및 기타 다른 개념들 간의 논리적 상호관계 등을 생
각해내고 정의하는 등, 모든 곳에 적용되는 용어이다.
5
6. Scalability
확장성(Scalability )은 컴퓨터 애플리케이션이나 제품 (하드웨어나 소프
트웨어)이, 사용자의 요구에 맞추기 위해 크기나 용량을 변경해도, 그 기
능이 계속하여 잘 동작할 수 있는 능력을 말한다. 크기 변화는 대체로 크
기나 용량 면에서 더 커지는 쪽으로 이루어진다.
확장성이 아닌 것:
•스피드나 성능(2GHz vs. 3GHz)
•운영체제(솔라리스 vs. 리눅스)
•소프트웨어 기술(Java vs. Python)
•하드웨어 플랫폼(AMD vs. Intel)
•스토리지 기술(SAN vs. NAS)
6
8. Shared Nothing Architecture
정의
“ A shared nothing architecture (SN) is a distributed
computing architecture in which each node is independent
and self-sufficient, and there is no single point of contention
across the system. “
- Wikipedia
PHP 창시자인 라스머스 레도르프(Rasmus Lerdorf)가 스케일링의 핵심원리
로 설명
어떤 하드웨어나 소프트웨어 리소스도 공유하지 않는 구조
서비스를 구성하는 리소스를 서버와 함께 분리함 으로서 개개의 서버의
failure로부터 격리하고 높은 scalability를 얻는 구조
쉬운 스케일 아웃
8
12. Reference Architecture - Facebook Web Architecture
3 service tiers:
Web/Apache
Memcached
MySQL
Uses:
Linux
PHP
13. Build Scalable Architecture Process
문제 발견
Identify Scalability Bottlenecks
Identify SPOFs and Availability Issues
Identify Downtime Impact Risk Zones
해결방안 적용
Vertical Scaling
Vertical Partitioning
Horizontal Scaling
Horizontal Partitioning
프로세스 반복
15. Step 2 - One Server - Vertical Scaling
개요
노드 수를 바꾸지 않고, 하드웨어 리소스를
증가 / 변경
장점
• 구조가 단순
• 구현이 쉽다
단점
• 하드웨어 증설에 한계
• 증설을 위한 다운시간이 필요함
• 비용이 지수적으로 증가함
• SPOF(Single Point of Failure)
15
16. Step 3 - Two Server - Vertical Partitioning (Services)
개요
분리된 노드에서 각 서비스를 운영함
장점
• 어플리케이션당 가용성이 증가함
• 태스크 기반에 특화/최적화/튜닝이 가능해
짐
• Context Switching이 줄어듦
• 유연성이 증가됨
단점
• 전체 가용성이 증가하지 않음
• 사이트가 다시 느려짐
• 확장성에 한계
• 쉽게 웹노드 CPU 한계치에 도달함
• Two SPOF(Single Point of Failure)
16
17. Vertical Partioning 이해
Vertical Partioning 이란
태스크와 기능을 분산시켜 노드수를 늘리는 것
각 노드 (혹은 클러스터)는 다른 태스크를 수행함
Vertical Partioning은 다양한 레이어에서 수행이 가능함
어플리케이션
서버
데이터
하드웨어 등
17
18. Step 4 - Horizontal Scaling (App Server)
개요
로드밸런싱을 통해 웹서버의 노드의 숫자를
늘림
장점
• 웹서버의 가용성이 증가됨
• 앱의 요건에 큰 변경이 없음
• 유연성이 증가됨
단점
• 사이트가 병목현상 존재
• IO 병목
• Database 병목
• SPOF(Single Point of Failure)
• Database
• Public Web Node
18
19. Horizontal Scaling 이해
Horizontal Scaling 이란
노드 복제를 통해 노드 수를 증가시킴
각 노드 (혹은 클러스터)는 동일한 태스크를 수행함
각 노드는 동일함
특별한 노드의 모음을 클러스터라고 칭함
Horizontal Scaling은 임의의 노드유형에서 수행이 가능함
웹서버(어플리케이션서버)
캐시 서버
DB 서버
19
20. Load Balancer - Removing SPOF
Active-Standby LB
Load Balanced App Server
Cluster에서는 로드밸런서가
SPOF
Setup LB in Active-Active or
Active-Passive mode
• Note: Active-Active nevertheless
assumes that each LB is
independently able to take up
Active-Active LB the load of the other
• If one wants ZERO downtime,
then Active-Active becomes
truly cost beneficial only if
multiple LBs (more than 3 to 4)
are daisy chained as Active-
Active forming an LB Cluster
20
21. Step 5 - Vertical Partitioning (Hardware)
개요
파일시스템을 외부 스토리지로 분리
(Partitioning)
장점
• DB서버의 스케일 업 가능
• DB서버의 퍼포먼스가 향상됨
단점
• 비용증가 (SAN)
21
22. Caching
연산결과를 저장하여 다음 번 요청에 결과를 재활용
캐싱은 퍼포펀스를 향상시킬 수 있음
Can't hit the DB all the time
MyISAM: r/w concurrency problems
InnoDB: better; not perfect
MySQL has to parse your queries all the time
Cache hit-ratios
Caching Methods
Generate Static Pages
Cache full pages
Cache partial pages
Cache data
Caching Patterns
Write-through
Write-behind(Write-back)
Sideline cache
22
32. Buddy Replication(Circular Replication)
Node B
Data B
Backup A
Replication
Replication
Node A Node C
Data A Data C
Backup E Backup B
Replication
Replication
Node E Replication Node D
Data E Data D
Backup D Backup C
32
33. Buddy Replication(Circular Replication)
Node B
Data B+A
Backup E
Replication
Node A Node C
Data A Replication Data C
Backup E Backup B+A
Replication
Node E Replication Node D
Data E Data D
Backup D Backup C
33
34. Replication Scaling - Reads
Reading scales well with replication
Great for (mostly) read-only applications
One server Two server
reads
reads reads
writes writes writes
34
35. Replication Scaling - Writes
Writing doesn’t scale with replication
All servers needs to do the same writes
reads reads reads reads reads
writes writes writes writes writes
35
36. Step 7 - Vertical / Horizontal Partitioning (DB, Sharding)
개요
데이터를 분할하여 DB 클러스터 수를 늘림
Load Balanced 옵션
App Servers
• Vertical Partitioning – 테이블/컬럼 분리
• Horizontal Partitioning – rows에 의한
분리
DB Cluster DB Cluster
36
37. Vertical Partitioning (DB)
일련의 테이블을 다른 DB로 옮긴다.
예) 소셜네트워크 – 사용자테이블과 진구테
이블은 분리된 DB Cluster에 저장한다
각 DB 클러스터는 다른 테이블을 갖는다.
App Cluster Application code or DAO / Driver code
or a proxy는 어떤 DB로 쿼리 할지 알고 있다
.
컬럼 단위로 분리해서 별도 DB로 나눌 수
있다.
DB Cluster 1 DB Cluster 2
Table 1 Table 3
Table 2 Table 4 단점
One cannot perform SQL joins or
maintain referential integrity (referential
integrity is as such over-rated)
Finite Limit
37
38. Horizontal Partitioning (DB)
레코드집합을 다른 DB로 옮긴다.
예) 소셜네트워크 – 각 DB Cluster 는 백만
사용자에 대한 모든 데이터를 포함시킴
각 DB클러스터는 동일한 테이블을 갖는다.
App Cluster Application code or DAO / Driver code
or a proxy는 주어진 row에 대해 어느 DB로
쿼리 할지 알고 있다.
단점
DB Cluster 1 DB Cluster 2 SQL unions for search type queries
Table 1 Table 1 must be performed within code
Table 2 Table 2
Table 3 Table 3
Table 4 Table 4
1 million users 1 million users
38
39. Step 8 - Seperating Sets (Federation)
글로벌 서비스 제공 시 활용
Global Redirector DNS를 통한 글로벌 라우팅
App App 장점
Servers Servers 무제한 확장이 가능함
Cluster Cluster 단점
데이터의 통합이 복잡해짐
DB Cluster DB Cluster Set내의 사이징 조절이 필요
Global App settings은 Set간
DB Cluster DB Cluster replication이 필요함
SET 1 SET 2
39