[212] large scale backend service develpment

43
Large Scale Backend Service Development using Node.js, Docker, and AWS Daniel Kang Sr. Software Engineer / Riot Games [email protected]

Transcript of [212] large scale backend service develpment

Large Scale Backend Service Development

using Node.js, Docker, and AWS

Daniel Kang Sr. Software Engineer / Riot Games

[email protected]

I’ll talk about…• Problems • Solutions

• Goals • Node.js, Redis, Docker and AWS

• Results

Problems

개발자님~❤����������� ������������������  

신규����������� ������������������  서비스����������� ������������������  런칭에����������� ������������������  필요한����������� ������������������  

서버����������� ������������������  개발����������� ������������������  이제����������� ������������������  시작해야하는데요

하...하겠습니다

출처:����������� ������������������  아이유����������� ������������������  Real����������� ������������������  Fantasy����������� ������������������  2012����������� ������������������  콘서트����������� ������������������  photo����������� ������������������  frame����������� ������������������  set

출처:����������� ������������������  MBC����������� ������������������  무한도전����������� ������������������  방송����������� ������������������  화면����������� ������������������  캡쳐

일단����������� ������������������  뭐����������� ������������������  대단한건����������� ������������������  아니고요����������� ������������������  그냥����������� ������������������  

동시����������� ������������������  접속����������� ������������������  유저는����������� ������������������  한����������� ������������������  10만명����������� ������������������  쯤?����������� ������������������  그리고����������� ������������������  건당����������� ������������������  평균����������� ������������������  처리속도는����������� ������������������  그냥����������� ������������������  

약����������� ������������������  0.1초����������� ������������������  이하면����������� ������������������  충분해요����������� ������������������  

(뭐����������� ������������������  구글도����������� ������������������  그����������� ������������������  정돈����������� ������������������  하잖아요?)

(난����������� ������������������  할����������� ������������������  수����������� ������������������  있다.����������� ������������������  난����������� ������������������  할����������� ������������������  수����������� ������������������  있다.)

출처:����������� ������������������  아이유����������� ������������������  Real����������� ������������������  Fantasy����������� ������������������  2012����������� ������������������  콘서트����������� ������������������  photo����������� ������������������  frame����������� ������������������  set

출처:����������� ������������������  MBC����������� ������������������  무한도전����������� ������������������  방송����������� ������������������  화면����������� ������������������  캡쳐

아참...����������� ������������������  그리고

그거����������� ������������������  ����������� ������������������  

다음����������� ������������������  달����������� ������������������  말����������� ������������������  까지����������� ������������������  ����������� ������������������  필요한데...����������� ������������������  가능하겠죵~?����������� ������������������  

(찡긋)

니가����������� ������������������  해����������� ������������������  볼래?

출처:����������� ������������������  http://kpopstreamonline.blogspot.com/2014/09/top-10-richest-k-pop-stars.html

출처:����������� ������������������  MBC����������� ������������������  무한도전����������� ������������������  방송����������� ������������������  화면����������� ������������������  캡쳐

하지만����������� ������������������  일단����������� ������������������  아이유니까����������� ������������������  

도전����������� ������������������  해����������� ������������������  보기로����������� ������������������  합니다

하지마����������� ������������������  미친놈아!

출처:����������� ������������������  MBC����������� ������������������  무한도전����������� ������������������  방송����������� ������������������  화면����������� ������������������  캡쳐

Project: Leaderboards

• 목표: 게임 내 특정 조건을 만족하는 플레이어들에게 실시간으로 보상 아이템을 주고, 플레이어들이 실시간으로 자신의 진행 상황을 확인 할 수 있는 API도 필요하다.

Solutions

Goals

• Scalability • Performance • Fast Iterations

Node.js

Multi-Core Systems• Reverse Proxying

• Hard to find balanced configs

• Tested w/ Nginx and HAProxy

• Node.js Native Clustering

• Worked pretty well for use cases

• Tested on 0.12.x

CPU Profiling• V8 profiling

• Node options :“--prof”

• Performance Bottlenecks

• Unnecessary HTTP routing

• Unnecessary encryption (crypto) module usages

• DEBUG enabled dependencies

• NewRelic Node.js agent: negative impact on performance

More on Node.js• Node versions: 0.10.x / 0.12.x

• ES6 features: generators and block scoping

• Linting

• Quality of code

• Identify potential issues

• WebStorm IDE

• Code analysis

• Interactive debugging features

• V8 profiling

Redis

Docker & AWS

ECSECS Tasks

ECS ServicesECS Task Definitions

ECS Container Instances

ECS Agent

EC2

IAM Roles

EC2 Instances

EC2 Security Groups

Elastic Load Balancer

CloudWatch Metrics

EC2 AMIs

VPCs

출처:����������� ������������������  나무위키����������� ������������������  (https://namu.wiki/w/몰라%20뭐야%20그거%20무서워)

AWS

EC2 as Docker Host• Amazon Linux HVM

• Enhanced networking enabled by default

• PV not recommended

• Larger instances => more performing spec

• c4.xlarge (4 cores / 7.5G memory)

• T2 class: too much CPU steals

• Increase ulimit / nproc

• Host: limits.conf, 90-nproc.conf

• Docker: "--default-ulimit nofile=64000:64000 --default-ulimit nproc=32000:32000"

Results

11,600,000 reqs/min

=c4.xlarge

130 instances

x 89,231 reqs/min

1,487 reqs/sec/instance

Latency

<14 ms

24,000,000 reqs/min

=c4.xlarge

130 instances

x184,615 reqs/min

3,077 reqs/sec/instance

Latency

<80 ms

[c4.4xlarge] $0.928 x 100 x 24h x 30d = $66,816 [c4.xlarge] $0.232 x 100 x 24h x 30d = $16,704

saved $50,112

Q & A