50
Amazon CloudFront Amazon S3 Mobile App Services SMARTSTUDY 박현우 / 스마트스터디 Oct 8, 2013 Using with on at

Using CloudFront and S3 at SMARTSTUDY

Embed Size (px)

DESCRIPTION

아마존코리아 주최 Cloudfront 세미나에서 발표했던 'Using CloudFront with S3 on Mobile App Services at SMARTSTUDY' 자료입니다.

Citation preview

Page 1: Using CloudFront and S3 at SMARTSTUDY

Amazon CloudFrontAmazon S3Mobile App ServicesSMARTSTUDY박현우 / 스마트스터디Oct 8, 2013

Usingwith

onat

Page 2: Using CloudFront and S3 at SMARTSTUDY

SMARTSTUDY

Page 3: Using CloudFront and S3 at SMARTSTUDY

스터디라니, 공부하는 동아리 같은 건가요?

공부는 항상 하고 있지만, 동아리는 아닙니다. 처음에는 모바일 플랫폼에서 ‘학습지’ 서비스를 만들려고 했습니다.

Study

Page 4: Using CloudFront and S3 at SMARTSTUDY

We’re그럼 스마트스터디는 어떤 회사인가요?

2010년 6월에 창업하여, 현재 약 36명이 서초동에 모여 다양한 모바일 앱을 개발하여 서비스하고 있습니다.

Page 5: Using CloudFront and S3 at SMARTSTUDY

Education그럼 교육용 앱과 서비스를 만드는 회사인가요?

꼭 그렇지만도 않습니다. 동영상, 만화, 사진, 게임 그리고 영유아 대상 앱도 만들어 서비스하고 있습니다.

Page 6: Using CloudFront and S3 at SMARTSTUDY

REQUISITES

Page 7: Using CloudFront and S3 at SMARTSTUDY

Enlarged모바일 기기의 화면 크기는 커지고 해상도는 높아지고 있습니다. 이에, 사용자는 점점 더 높은 품질의 콘텐츠를 요구하고, 필연적인 용량 증가로 이어집니다.

Page 8: Using CloudFront and S3 at SMARTSTUDY

Globally한국 뿐 아니라 해외 시장에도 앱을 출시하였고, 이에 지역 구별 없이 사용자에게 대용량 콘텐츠를 전달해야 합니다.

Page 9: Using CloudFront and S3 at SMARTSTUDY

Fast모바일 디바이스의 네트워크 속도는 지속적으로 향상되고 있고, 사용자는 인내심이 점점 줄어들고 있습니다.

Page 10: Using CloudFront and S3 at SMARTSTUDY

Redundant새로운 경쟁자가 끊임 없이 나타나는 시장에서의 서비스는 늘 안정적으로 운영되어야 하며, 사용자에게 불쾌함을 주면 안됩니다.

Page 11: Using CloudFront and S3 at SMARTSTUDY

Inexpensive사용자에게 만족스러운 가격에 콘텐츠를 공급함과 동시에, 회사가 목표하는 이익을 내기 위해서는 전달 과정에 들어가는 비용이 중요합니다.

Page 12: Using CloudFront and S3 at SMARTSTUDY

We have to serve enlarged contents globally as fast as possible with

high redundancy,inexpensively.

Page 13: Using CloudFront and S3 at SMARTSTUDY

We have to serve enlarged contents globally as fast as possible with

high redundancy,inexpensively.

enlargedglobally fast

redundantinexpensive

Page 14: Using CloudFront and S3 at SMARTSTUDY

HOW TO USE

Page 15: Using CloudFront and S3 at SMARTSTUDY

Amazon Simple Storage Service

지역별로 구성 가능한 스토리지 서비스입니다.비교적 저렴한 가격에 안전하고 신뢰성 높은 저장 장소를 구성할 수 있습니다.

S3

Page 16: Using CloudFront and S3 at SMARTSTUDY

S3 vs Disk

S3 Disk특성

속도

신뢰성

다중 연결

저장 비용

Object store Physical device

느림 매우 빠름

높음 낮음

가능 불가능

보통 저렴

Page 17: Using CloudFront and S3 at SMARTSTUDY

S3 vs EBS

S3 EBS특성

속도

신뢰성

다중 연결

저장 비용

Object store Block store

느림 빠름

높음 보통

가능 불가능

보통 보통

Page 18: Using CloudFront and S3 at SMARTSTUDY

S3 vs Glacier

S3 Glacier특성

즉시 사용

신뢰성

전송 비용

저장 비용

Object store Backup store

가능 불가능*

높음 매우 높음

보통 보통

보통 저렴

* 기본 3-5시간의 준비시간 소요

Page 19: Using CloudFront and S3 at SMARTSTUDY

EBS vs S3 vs Glacier

EBS S3 Glacier

신속성

신뢰성

저장 비용

전송 비용

높음 보통 낮음

보통 높음 매우 높음

10 ~10 1

1* 1 1

* EBS via EC2

Page 20: Using CloudFront and S3 at SMARTSTUDY

Amazon CloudFront : Content Delivery

S3 만으로도 최종 사용자에게 콘텐츠를 전달할 수 있지만, CloudFront 를 통해 더 저렴한 가격에 보다 빠른 속도로 서비스가 가능합니다.

CloudFront

Page 21: Using CloudFront and S3 at SMARTSTUDY

Origin to Edge

•HTTP / HTTPS 요청이 있을 때,

•가까운 Edge를 찾아,

•해당 Edge에 캐시가 있는지 확인하고,

•캐시가 없거나, 새로 받아야 한다면,

•Origin 서버에서 데이터를 전송합니다.

Page 22: Using CloudFront and S3 at SMARTSTUDY

Response

Origin / S3

Copy fromNear Edge

Origin to Edge

Forward

Look upcache

Far EdgeCloudFront

Request

Page 23: Using CloudFront and S3 at SMARTSTUDY

Contents to S3

•REST API

•Tools

•GUI app

•File System

•Command line toolS3 Bucket

Page 24: Using CloudFront and S3 at SMARTSTUDY

S3 Tools

Cyberduck s3fs s3cmd

형태

편의성

용도

특징

GUI File System CLI

보통 높음 낮음

조회 / 테스트 디스크처럼 사용 대용량 처리

- 느림 Invalidation

Page 25: Using CloudFront and S3 at SMARTSTUDY

S3 Tools

s3cmd aws-cli

기반

기능

제작

비고

Python / httplib Python / boto

S3 + CloudFront All AWS

Michal Ludvig AWS

업데이트가 느림 따끈따끈한 프로젝트

Page 26: Using CloudFront and S3 at SMARTSTUDY

s3cmd

•Sync 명령어가 있어서 편리합니다.

•Multipart Upload 를 통해 대용량 파일을 나누어 올릴 수 있습니다.

•CloudFront 의 캐시 제어를 위한 Invalidation 요청이 자동으로 이뤄집니다.

Page 27: Using CloudFront and S3 at SMARTSTUDY

Origin / S3

Far Edge

Invalidation

Near Edge Invalidation

Invalidation

CloudFront

InvalidationRequest

Flush caches

Page 28: Using CloudFront and S3 at SMARTSTUDY

Performance

•환경

•총 용량 60GB, 약 3만개 파일.

•원본 : i7 2500K + SATA Disk

•대상 : Tokyo region bucket

•전체 비교에 약 8분 정도 걸림.

•특정 디렉토리만 비교하는 것도 가능.

Page 29: Using CloudFront and S3 at SMARTSTUDY

Tips

•Multipart Upload 된 파일에는 MD5 해시 정보가 없어, 날짜로 비교해서 Sync 수행.

•Invalidation 요청은 한 달에 천 개의 파일까지 무료, 이후에는 과금.

•Invalidation 요청은 동시에 3개까지만.

•s3cmd cfinvalinfo 로 확인 가능.

Page 30: Using CloudFront and S3 at SMARTSTUDY

Parallel upload

•Multipart Upload 인 경우, Upload Id 를 발급받아, 여러 파트로 나눠서 업로드 가능.

•각 파트를 동시에 업로드하는 것이 가능하므로, 큰 파일을 빠르게 S3 로 전송할 수 있습니다.

•s3cmd-parallel 등의 변종 존재.

Page 31: Using CloudFront and S3 at SMARTSTUDY

WHERE TO USE

Page 32: Using CloudFront and S3 at SMARTSTUDY

동영상, 만화책 등 다운로드형 콘텐츠 전달

광고 시스템 등을 위한 Storage API 의 백엔드

HTTP Live Streaming (HLS)

Page 33: Using CloudFront and S3 at SMARTSTUDY

Origin / S3

s3cmd

Media DeployServer

Transcoder

Contents to S3

MediaServer

Page 34: Using CloudFront and S3 at SMARTSTUDY

Contents to S3

Origin / S3

s3cmd

DeployServer

Transcoder

MediaServer

Transcoder Package (npk)

Streamablevideo content

Meta data / Thumbs

GNU Flash

ffmpeg / libavMPEG-2

Flash / SWF

Page 35: Using CloudFront and S3 at SMARTSTUDY

Storage APIServer

Request

Request

Origin / S3

boto

Storage API

AD APIServer

Event APIServer

Page 36: Using CloudFront and S3 at SMARTSTUDY

HTTP Live Streaming

Origin / S3

Low level segments

Mid level segments

High level segments

Index file (m3u8)

s3cmd

SegmenterOriginalVideo

HLS KeyServer

HLS Key PairsREST

Page 37: Using CloudFront and S3 at SMARTSTUDY

THEN

Page 38: Using CloudFront and S3 at SMARTSTUDY

We have to serve enlarged contents globally as fast as possible with

high redundancy,inexpensively.

enlargedglobally fast

redundantinexpensive

Page 39: Using CloudFront and S3 at SMARTSTUDY

충분히 빠르고안정적이며

비싸지 않습니다

Page 40: Using CloudFront and S3 at SMARTSTUDY

국내 CDN피크 트래픽 기준

•350Mbps/M•$ 6.00/Mbps

= $ 2,100

CloudFront총 전송량 기준

•10TB/M•$ 0.190/GB

= $ 1,900** 한 Bucket 에서 다른 Edge 로 전달하는 비용 제외

Page 41: Using CloudFront and S3 at SMARTSTUDY

설마 아직도비싸다고 생각하시나요

Page 42: Using CloudFront and S3 at SMARTSTUDY

매월 10TB 이상 사용한다면

ReservedCapacity Pricing

Page 43: Using CloudFront and S3 at SMARTSTUDY

약정 2년국내 CDN피크 트래픽 기준

•350Mbps/M•$ 6.00/Mbps

= $ 2,100

Reserved CapacityCloudFront총 전송량 기준

•10TB/M•약속된 금액

= $ 1,075** 한 Bucket 에서 다른 Edge 로 전달하는 비용 제외

Page 44: Using CloudFront and S3 at SMARTSTUDY

Monthly Fee Dec 2012 Sep 2013

CF Fee

S3 Fee

Transmittedin GB

Ratio

$ 4672 $ 2413

$ 23 $ 21

28390 23533

0.165 0.103

Page 45: Using CloudFront and S3 at SMARTSTUDY

WRAP UP

Page 46: Using CloudFront and S3 at SMARTSTUDY

더 작게

•최적의 옵션으로 미디어를 가공.

•각 플랫폼에 맞게 별도의 파일을 준비.

•저장 비용은 전송 비용보다 싸다!

Page 47: Using CloudFront and S3 at SMARTSTUDY

정적으로

•자주 바뀌는 파일은 CloudFront 에 어울리지 않음.

• Invalidation 요청이 때로는 10분 정도 걸림.

•정적이지 않은 파일들은 아직도 웹 서버를 사용 중.

Page 48: Using CloudFront and S3 at SMARTSTUDY

스트리밍 가능하게

•모바일 네트워크는 아직 느리므로,

•콘텐츠 다운로드가 끝날 때까지 사용자를 기다리게 하지 말자. 바로 사용할 수 있도록.

Page 49: Using CloudFront and S3 at SMARTSTUDY

Gnashhttp://www.gnu.org/software/gnash/

FFmpeghttp://www.ffmpeg.org/

qtfaststarthttps://github.com/danielgtaylor/qtfaststart

npkhttps://github.com/lqez/npk

s3cmdhttp://s3tools.org/

Page 50: Using CloudFront and S3 at SMARTSTUDY

Amazon CloudFrontAmazon S3Mobile App ServicesSMARTSTUDY박현우 / 스마트스터디Oct, 2013

Usingwith

onat