scalable web architecture

40
Scalable Web Architecture 2010.12. DM 본본 본본본본본본 1

Upload: steve-min

Post on 31-May-2015

1.791 views

Category:

Documents


1 download

DESCRIPTION

Scalable web architecture

TRANSCRIPT

Page 1: Scalable web architecture

Scalable Web Architecture

2010.12.DM 본부

기술개발담당

1

Page 2: Scalable web architecture

index

1. Desirable Properties of a Web App

2. Reference Architecture1. Flickr Architecture2. LiveJournal Architecture3. Facebook Architecture

3. Build Scalable Architecture Process1. Step 1 - One Server2. Step 2 - One Server - Vertical Scaling3. 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

Page 3: Scalable web architecture

Desirable Properties of a Web App

•확장성 (Scalability)

•고가용성 (High Availability)

•성능 (Performance)

•응답성 (Responsiveness)

•관리성 (Manageability)

•저비용 (Low Cost)

3

Page 4: Scalable web architecture

High Availability

고가용성 (HA) 이란 바람직한 정도로 긴 시간동안 지속적으로 운영이 가능한 시스템이나 컴포넌트를 가리킨다 . 가용성이란 흔히 "100% 가용 " 등과 같이 상대적으로 측정되거나 또는 " 절대 고장나지 않음 " 등과 같이 표현될 수 있다 . 널리 쓰이고 있지만 달성하기 결코 쉽지 않은 시스템 및 제품에 대한 가용성 표준에 흔히 “파이브 나인 (five 9) 이라고 부르는 99.999%의 가용성을 들 수 있다 .

4

Page 5: Scalable web architecture

Architecture

아키텍처란 , 프로세스와 전체적인 구조나 논리적 요소들 그리고 컴퓨터와 운영체계 , 네트웍 및 기타 다른 개념들 간의 논리적 상호관계 등을 생각해내고 정의하는 등 , 모든 곳에 적용되는 용어이다 .

5

Page 6: Scalable web architecture

Scalability

확장성 (Scalability ) 은 컴퓨터 애플리케이션이나 제품 (하드웨어나 소프트웨어 ) 이 , 사용자의 요구에 맞추기 위해 크기나 용량을 변경해도 , 그 기능이 계속하여 잘 동작할 수 있는 능력을 말한다 . 크기 변화는 대체로 크기나 용량 면에서 더 커지는 쪽으로 이루어진다 .

확장성이 아닌 것 :•스피드나 성능 (2GHz vs. 3GHz)•운영체제 ( 솔라리스 vs. 리눅스 )•소프트웨어 기술 (Java vs. Python)•하드웨어 플랫폼 (AMD vs. Intel)•스토리지 기술 (SAN vs. NAS)

6

Page 7: Scalable web architecture

Vertical vs. Horizontal

7

Scale Up Scale Out

Page 8: Scalable web architecture

Shared Nothing Architecture

정의

PHP 창시자인 라스머스 레도르프 (Rasmus Lerdorf) 가 스케일링의

핵심원리로 설명

어떤 하드웨어나 소프트웨어 리소스도 공유하지 않는 구조

서비스를 구성하는 리소스를 서버와 함께 분리함 으로서 개개의 서버의

failure 로부터 격리하고 높은 scalability 를 얻는 구조

쉬운 스케일 아웃

8

“ A shared nothing architecture (SN) is a distributed computing architecture in which each node is inde-pendent and self-sufficient, and there is no single point of contention across the system. “

- Wikipedia

Page 9: Scalable web architecture

Reference Architecture - Flickr Architecture

9

Page 10: Scalable web architecture

Reference Architecture - LiveJournal Architecture

10

Page 11: Scalable web architecture

Reference Architecture - Facebook Architecture

11

Page 12: Scalable web architecture

Reference Architecture - Facebook Web Architecture

3 service tiers:Web/ApacheMemcachedMySQL

Uses:LinuxPHP

Page 13: Scalable web architecture

Build Scalable Architecture Process

문제 발견Identify Scalability BottlenecksIdentify SPOFs and Availability IssuesIdentify Downtime Impact Risk Zones

해결방안 적용Vertical ScalingVertical PartitioningHorizontal ScalingHorizontal Partitioning

프로세스 반복

Page 14: Scalable web architecture

Step 1 - One Server

14

Page 15: Scalable web architecture

Step 2 - One Server - Vertical Scaling

개요노드 수를 바꾸지 않고 , 하드웨어 리소스를

증가 / 변경

장점• 구조가 단순• 구현이 쉽다

단점• 하드웨어 증설에 한계• 증설을 위한 다운시간이 필요함• 비용이 지수적으로 증가함• SPOF(Single Point of Failure)

15

Page 16: Scalable web architecture

Step 3 - Two Server - Vertical Partitioning (Services)

16

개요분리된 노드에서 각 서비스를 운영함

장점• 어플리케이션당 가용성이 증가함• 태스크 기반에 특화 / 최적화 / 튜닝이

가능해짐• Context Switching 이 줄어듦• 유연성이 증가됨

단점• 전체 가용성이 증가하지 않음• 사이트가 다시 느려짐

• 확장성에 한계• 쉽게 웹노드 CPU 한계치에 도달함

• Two SPOF(Single Point of Fail-ure)

Page 17: Scalable web architecture

Vertical Partioning 이해

Vertical Partioning 이란 태스크와 기능을 분산시켜 노드수를 늘리는 것 각 노드 ( 혹은 클러스터 ) 는 다른 태스크를 수행함

Vertical Partioning 은 다양한 레이어에서 수행이 가능함 어플리케이션 서버 데이터 하드웨어 등

17

Page 18: Scalable web architecture

Step 4 - Horizontal Scaling (App Server)

18

개요로드밸런싱을 통해 웹서버의 노드의 숫자를 늘림

장점• 웹서버의 가용성이 증가됨• 앱의 요건에 큰 변경이 없음• 유연성이 증가됨

단점• 사이트가 병목현상 존재

• IO 병목• Database 병목

• SPOF(Single Point of Failure)• Database • Public Web Node

Page 19: Scalable web architecture

Horizontal Scaling 이해

Horizontal Scaling 이란 노드 복제를 통해 노드 수를 증가시킴 각 노드 ( 혹은 클러스터 ) 는 동일한 태스크를 수행함 각 노드는 동일함 특별한 노드의 모음을 클러스터라고 칭함

Horizontal Scaling 은 임의의 노드유형에서 수행이 가능함 웹서버 ( 어플리케이션서버 ) 캐시 서버 DB 서버

19

Page 20: Scalable web architecture

Load Balancer - Removing SPOF

Load Balanced App Server Cluster 에서는 로드밸런서가 SPOFSetup LB in Active-Active or Active-Passive mode

• Note: Active-Active never-theless assumes that each LB is independently able to take up the load of the other

• If one wants ZERO down-time, then Active-Active becomes truly cost benefi-cial only if multiple LBs (more than 3 to 4) are daisy chained as Active-Ac-tive forming an LB Cluster

20

Active-Standby LB

Active-Active LB

Page 21: Scalable web architecture

Step 5 - Vertical Partitioning (Hardware)

2121

개요파일시스템을 외부 스토리지로 분리

(Partitioning)

장점• DB 서버의 스케일 업 가능• DB 서버의 퍼포먼스가 향상됨

단점• 비용증가 (SAN)

Page 22: Scalable web architecture

Caching

22

연산결과를 저장하여 다음 번 요청에 결과를 재활용캐싱은 퍼포펀스를 향상시킬 수 있음Can't hit the DB all the time

MyISAM: r/w concurrency problems InnoDB: better; not perfectMySQL has to parse your queries all the time

Cache hit-ratiosCaching Methods

Generate Static PagesCache full pagesCache partial pagesCache data

Caching PatternsWrite-throughWrite-behind(Write-back)Sideline cache

Page 23: Scalable web architecture

Write-through cache

23

App Server

Cache

Database

Page 24: Scalable web architecture

Write-back cache

24

App Server

Cache

Database

① ②

Page 25: Scalable web architecture

Sideline cache

25

App ServerCache

Database

Page 26: Scalable web architecture

Step 6 - Horizontal Scaling (DB Scaling)

26

개요DB 서버의 노드를 증가시킴

옵션• Shared nothing Cluster• Real Application Cluster (or

Shared Storage Cluster)

장점• 웹서버가 늘어남에따라 DB 서버 노드도

추가 할 수 있다• DB 서버가 더 이상 SPOF 가 아니다

단점• 증가에 한계가 있다

Page 27: Scalable web architecture

Shared Nothing Cluster

각 DB 서버 노드가 완전한 Database copy 를 가지고 있는 것

각 DB 서버 노드간에는 아무것도 공유되지 않음

DB Replication 을 통해 완성됨

27

Page 28: Scalable web architecture

Replication

Master-Slave Replication

Tree Replication

Master-Master Replication

Buddy Replication

28

Page 29: Scalable web architecture

Master-Slave Replication

29

Page 30: Scalable web architecture

Tree Replication (Relay slave replication)

30

Page 31: Scalable web architecture

Master-Master Replication

31

Page 32: Scalable web architecture

Buddy Replication(Circular Replication)

32

Node BData B

Backup A

Node CData C

Backup B

Node DData D

Backup C

Node EData E

Backup D

Node AData A

Backup E

Replication

Replication

Replication

Replication

Replication

Page 33: Scalable web architecture

Buddy Replication(Circular Replication)

33

Node BData B+A Backup E

Node CData CBackup

B+A

Node DData D

Backup C

Node EData E

Backup D

Node AData A

Backup E

Replication

Replication

Replication

Replication

Page 34: Scalable web architecture

Replication Scaling - Reads

Reading scales well with replication

Great for (mostly) read-only applications

34

One server Two server

writes

capaci

ty

reads

writes writes

reads reads

Page 35: Scalable web architecture

Replication Scaling - Writes

Writing doesn’t scale with replication

All servers needs to do the same writes

35

writes

reads

writes

reads

writes

reads

writes

reads

writes

reads

capaci

ty

Page 36: Scalable web architecture

Step 7 - Vertical / Horizontal Partitioning (DB, Sharding)

36

개요데이터를 분할하여 DB 클러스터 수를 늘림

옵션• Vertical Partitioning – 테이블 / 컬럼

분리• Horizontal Partitioning – rows 에

의한 분리

DB Clus-ter

Load BalancedApp Servers

DB Clus-ter

Page 37: Scalable web architecture

Vertical Partitioning (DB)

37

일련의 테이블을 다른 DB 로 옮긴다 . 예 ) 소셜네트워크 – 사용자테이블과

진구테이블은 분리된 DB Cluster 에 저장한다각 DB 클러스터는 다른 테이블을 갖는다 .Application code or DAO / Driver

code or a proxy 는 어떤 DB 로 쿼리 할지 알고 있다 .

컬럼 단위로 분리해서 별도 DB 로 나눌 수 있다 .

단점 One cannot perform SQL joins or

maintain referential integrity (ref-erential integrity is as such over-rated)

Finite Limit

App Cluster

DB Cluster 1Table 1Table 2

DB Cluster 2Table 3Table 4

Page 38: Scalable web architecture

Horizontal Partitioning (DB)

38

레코드집합을 다른 DB 로 옮긴다 . 예 ) 소셜네트워크 – 각 DB Cluster 는 백만

사용자에 대한 모든 데이터를 포함시킴각 DB 클러스터는 동일한 테이블을 갖는다 .Application code or DAO / Driver

code or a proxy 는 주어진 row 에 대해 어느 DB 로 쿼리 할지 알고 있다 .

단점SQL unions for search type

queries must be performed within code

App Cluster

DB Cluster 1Table 1Table 2Table 3Table 4

DB Cluster 2Table 1Table 2Table 3Table 4

1 million users 1 million users

Page 39: Scalable web architecture

Step 8 - Seperating Sets (Federation)

39

글로벌 서비스 제공 시 활용DNS 를 통한 글로벌 라우팅

장점무제한 확장이 가능함

단점데이터의 통합이 복잡해짐Set 내의 사이징 조절이 필요Global App settings 은 Set 간

replication 이 필요함

Global Redirector

App ServersCluster

DB Cluster

DB Cluster

SET 1

App ServersCluster

DB Cluster

DB Cluster

SET 2

Page 40: Scalable web architecture

엠넷은 ?

?40