Upload
amazon-web-services-korea
View
1.191
Download
16
Embed Size (px)
Citation preview
AWS와 부하 테스트의절묘한 만남김무현, AWS 솔루션즈 아키텍트
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
런치 준비완료?
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
부하 테스트 사전 수행아니면
서비스 런치 후초조하게 기도하기?
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
부하 테스트에 대해서살펴봅시다.
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
부하 테스트란 무엇일까요?
소프트웨어 시스템 또는 컴퓨팅 장치에 요청을 보내고응답을 측정하는 테스트 방법
부하 테스트를 통해서 …
• 현재 서비스 구성의 제한(limit)을 찾기
• 원하는 부하를 수용할 수 있게끔 구성되었는지 확인
• 병목 지점을 찾고 병목 현상을 제거
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
부하 테스트 (Load Test)(1)
소프트웨어 시스템에 요청을 보내서응답을 측정하는 절차
• to determine a system's behavior under both normal and anticipated peak load conditions
• to identify the maximum operating capacity of an application as well as any bottlenecks and determine which element is causing degradation
부하 테스트와 스트레스 테스트
스트레스 테스트 (Stress Test)(2)
시스템의 안정성을 결정하기 위해서수행되는 의도적인 심한 테스트. 일반적인운영 용량을 넘은 테스트를 수행하여결과를 관찰함
• to determine breaking points or safe usage limits
• to confirm mathematical model is accurate enough in
predicting breaking points or safe usage limits
• to confirm intended specifications are being met
• to determine modes of failure (how exactly a system
fails)
• to test stable operation of a part or system outside
standard usage(1)출처: https://en.wikipedia.org/wiki/Load_testing(2)출처: https://en.wikipedia.org/wiki/Stress_testing
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
부하 테스트 수행전에 고려해야할 내용들
• 충분한 테스트용 서버 자원 확보
• 테스트 시, 블랙박스 혹은 격리된 환경 제어
• 글로벌 기반의 부하 생성
• 높은 비용과 불규칙적인 사용성에 대한 주의
• 높은 아키텍처 복잡성에 대한 주의
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS와 부하 테스트의조합은 어떨까요?
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS 클라우드 기반의 부하 테스트의 장점
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS 클라우드 기반의 부하 테스트의 장점
효율적인 비용 • 테스트 조건에 맞는 인스턴스 사용• 워밍업 테스트에는 작은 인스턴스 사용• 테스트 종료 후, 자원 반환
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS 클라우드 기반의 부하 테스트의 장점
충분하고 유연한자원
• 필요한 규모의 테스트 자원 확보 가능• 오토스케일팅을 통한 부하 테스트시 자원 자동 증가 및
감소
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS 클라우드 기반의 부하 테스트의 장점
글로벌 리전활용
• 전 세계 리전을 활용한 부하 테스트 수행
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS 클라우드 기반의 부하 테스트의 장점
쉽고 단순한아키텍처구성 및 관리
• CloudFormation을 이용한 동일한 운영, 테스트 환경의손쉬운 구성
• 관리형 서비스, Serverless 서비스를 이용한 부하 테스트환경 운영 간소화 및 단순화
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
부하 테스트 수행은 어떻게하는지 알아봅시다
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
단계별로 수행하는 부하 테스트
• 비결합(Loosely Coupled)된 개별 컴포넌트에 대한 부하테스트
• 내부 서비스에 대한 부하 테스트
• 외부 서비스에 대한 부하 테스트
• 전체 스택에 대해 부하 테스트
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Public Subnet
Master
Database
Internal Services Servers
Private
Subnet
Load Test
Scripts
Metrics
Collection &
Graphing
Load
Generators
Private or
Public Subnet
AWS에 있는 컴포넌트 및 서비스 테스트
• 같은 VPC에 부하테스트 구성
• JMeter를 이용한 DB 성능 테스트
• ORM 부하 확인
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• DirectConnect 또는VPN 성능 검증
• AWS에 Cache 또는Proxy cache가필요한지 확인
• IP 주소가 겹치지않도록
데이터센터에 있는 서비스 테스트
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
외부 서비스에 대한 부하 테스트
External
APIs
Internet
Load Test
ScriptsRegion 1
Metrics
Collection &
Graphing
Load
GeneratorsLoad Test
ScriptsRegion 2
Metrics
Collection &
Graphing
Load
Generators
Load Test
ScriptsRegion 3
Metrics
Collection &
Graphing
Load
Generators
부하 테스트수행 전에외부 서비스에공지가필요한지확인하자
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
전체 스택에 대해 부하 테스트
• 전체 게임 플레이 세션을 시뮬레이션
• 다양한 지역에서 테스트 수행
• 전체 인프라에 대한 전체적인 뷰
• 파이프라인상에서 병목 확인
• 오토-스케일링 정책을 세우는데 도움을 줌
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
전체 스택에 대해 부하 테스트
Corporate Data Center
Load Test
Deployment
External
APIs
Internet
Internet
Direct
Connect
Load Test
Scripts
region
Metrics
Collection &
Graphing
Load
Generators
region
region
Internet
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
전체 스택에 대해 부하 테스트 어떻게 이뤄지나요?
DevelopersDevelopersDevelopers
Load Test Deployment
S3 Bucket
Developer Workstation
Small Load Test to Verify
Scripts
Upload Finished Test Scenarios to
S3
Download Scenarios
Upload Raw Results &
Aggregates
Full Scale Load Testing
EMR + RedShift,
Graphite or Splunk et al.
Configuration Management
Server
Pushes Configuration
Code Repository
Load Test Stack
Send Data
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
3-티어에 대한 부하 테스트전략
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
3-티어에 대한 부하 테스트 수행
1. 최초 ‘WEB’ 을 출력하는 웹페이지를 대상으로 동시연결성에 대한 테스트 수행
2. 결과 평가
3. 최적화 진행
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
3-티어에 대한 부하 테스트 수행
1. 웹 서버를 통해 애플리케이션서버에서 넘겨 받은‘APPLICATION’ 을 출력하는웹 페이지를 대상으로 동시연결성에 대한 테스트 수행
2. 결과 평가
3. 최적화 진행
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
3-티어에 대한 부하 테스트 수행
1. 데이터베이스에서 최소한의쿼리 결과를 전달 받아출력하는 웹 페이지를대상으로 동시 연결성에 대한테스트 수행
2. 결과 평가
3. 최적화 진행
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
3-티어에 대한 부하 테스트 수행
1. 3-tier 스택 전체를 대상으로애플리케이션 로직이 적용된페이지에 동시 연결성에 대한테스트 수행
2. 결과 평가
3. 최적화 진행
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
3-티어에 대한 부하 테스트 수행
1. 4번을 기반으로 다양한시나리오를 지정하여 테스트수행
2. (얻고자 하는 지표 기준에대해서) 결과 평과
3. 최적화 진행
시나리오별 테스트를 해야죠!
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
각 레이어별로는 어떤 것을고려해야할까요?
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
각 레이어별 고려사항
• 네트워크 용량 확인
• 부하 생성 클라이언트
• 로드 밸런싱
(Elastic Load Balancing)
• 서버 인스턴스
• 어플리케이션 서버
• 어플리케이션
• 데이터베이스
아웃바운드 연결에 예상되는 최대부하를 처리가능한지?
• EC2 인스턴스 타입 – Enhanced Networking
• VPN 네트워크 성능 등
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
각 레이어별 고려사항
• 네트워크 용량 확인
• 부하 생성 클라이언트
• 로드 밸런싱
(Elastic Load Balancing)
• 서버 인스턴스
• 어플리케이션 서버
• 어플리케이션
• 데이터베이스
• 원하는 부하양을 생성할 수 있는충분한 인스턴스 확보
• 부하 생성 클라이언트 특징확인필요
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
각 레이어별 고려사항
• 네트워크 용량 확인
• 부하 생성 클라이언트
• 로드 밸런싱
(Elastic Load Balancing)
• 서버 인스턴스
• 어플리케이션 서버
• 어플리케이션
• 데이터베이스
• Backend / Target 인스턴스들이요구량 증가에 신속하게 대응가능한지 (Auto Scaling)
• 급격한 부하 증가 시나리오인 경우,사전 ELB 확장
• Keep-Alive 설정을 통한 불필요한연결 재수립 방지
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
각 레이어별 고려사항
• 네트워크 용량 확인
• 부하 생성 클라이언트
• 로드 밸런싱
(Elastic Load Balancing)
• 서버 인스턴스
• 어플리케이션 서버
• 어플리케이션
• 데이터베이스
• 서버 성능 최적화
• Open Files Limit
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
각 레이어별 고려사항
• 네트워크 용량 확인
• 부하 생성 클라이언트
• 로드 밸런싱
(Elastic Load Balancing)
• 서버 인스턴스
• 어플리케이션 서버
• 어플리케이션
• 데이터베이스
• Thread 기반인 경우 Thread Pool 크기가 적당한지
• Event 기반 비동기 형태의어플리케이션 서버 사용
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
각 레이어별 고려사항
• 네트워크 용량 확인
• 부하 생성 클라이언트
• 로드 밸런싱
(Elastic Load Balancing)
• 서버 인스턴스
• 어플리케이션 서버
• 어플리케이션
• 데이터베이스
어플리케이션 코드 – Unit 테스트, Lint• 잘못된 방식의 프레임워크, API
사용• Blocking 코드• 불필요한 연산 또는 테스트 코드
어플리케이션 프레임워크• 웹 프레임워크나 ORM(Object-
relational mapping) 라이브러리오류
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
각 레이어별 고려사항
• 네트워크 용량 확인
• 부하 생성 클라이언트
• 로드 밸런싱
(Elastic Load Balancing)
• 서버 인스턴스
• 어플리케이션 서버
• 어플리케이션
• 데이터베이스
• CPU 사용률과 응답 시간 확인
• 설정에 따라 더 요구되는 자원이있는지 점검
• 메모리 사용률 확인
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
꼭 알아야할 팁
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
부하테스트 시 유용한 팁 모음
• 가능한 모든 것을 자동화
• 로그 기록과 확인
• 적절한 인스턴스의 선택
• 비용 최소화
• 다양한 도구와 서비스의 복합적 활용
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
그러면 부하 테스트를 위한도구들은 어떤것이 있을까요
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
부하 테스트 도구들
EC2설치형
서비스형AWS활용형
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
부하 테스트 도구들
EC2설치형
Grinder• Agent 기반 부하 생성• Thread 기반 구현으로 성능, 동시성에 제한이 있음
Gatling• Akka와 Netty 기반의 Scala로 구현된 부하 테스트 프레임워크• Async IO 기반으로 높은 성능 제공• 시나리오 DSL 작성
Tsung• HTTP, Websocket, 인증시스템, 데이터베이스, MQTT 등 TCP 기반의
다양한 프로토콜
Vegeta• HTTP 부하 테스트• 초당 일정한 속도록 특정 수치의 요청을 지속
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
부하 테스트 도구들
EC2설치형
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
부하 테스트 도구들
RedLine13
• AWS Advanced Technology Partner• 부하 테스트 수행 서비스 제공• AWS IAM 계정을 이용한 Agent 설치• 스팟 인스턴스 활용을 통한 비용 절감• JMeter, Gatling, Python, PHP 및 NodeJS 지원
서비스형
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
부하 테스트 도구들
RedLine13
서비스형
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
부하 테스트 도구들
Loader.io
• 클라우드 기반의 부하테스트 서비스• 대상 서버 지정, 원하는 동시성 지정 등• 테스트 리플레이 가능
서비스형
출처: loader.io
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
부하 테스트 도구들
Bees with Machine Guns• EC2 인스턴스를 지정한 개수만큼 생성해서 부하 테스트 수행• 스팟 인스턴스 활용 옵션• ApacheBench 기반 (hurl 사용 가능)
AWS활용형
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
부하 테스트 도구들
Goad• AWS Lambda를 이용한 분산 부하 테스트• 대상 URL에 부하 테스트 수행 후, AWS SQS를 통한 결과 취합
AWS활용형
Amazon SQS
$ goad λ 수행
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
부하 테스트 도구 선택은?
도구 명 활용 방법
JMeter 웹 애플리케이션 내에서 사용자의 행동 흐름에 대해 부하 테스트를 하고 싶을 때
Tsung API 가 수용할 수 있는 최대치의 부하를 알고 싶을 때
Vegeta어떤 API 에 대해 초당 특정 수치의 요청이 지속될 경우 발생하는 상황을 파악하고싶을 때
Goad 부하 생성 클라이언트 구성을 포함한 부하 테스트 관련 인프라 구성을 피하고 싶을 때
RedLine13JMeter 로 테스트 플랜을 작성하여 활용을 원하지만, 비용을 최소화 하고 싶고 사용한만큼만 비용이 발생하길 원할 때
Blazemeter높은 동시성을 위해 JMeter 의 Remote Testing 기능을 활용하고 싶지만, 테스트 플랜작성에 집중하고, 부하 테스트 관련 인프라 구성은 하고 싶지 않을 때
Loader.io부하 테스트 관련 인프라 구성을 하고 싶지 않고, Tsung 과 비슷한 목적으로 사용하고싶을 때
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
데모 1AWS EC2 자동 구성Bees with Machine Guns!
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Bees with Machine Guns
$ bees up $ bees attack $ bees down
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Bees with Machine Guns
$ bees up
EC2 on-demand 또는 Spot리전 및 가용영역인스턴스 타입인스턴스 개수AMI서브넷보안 그룹SSH 키
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Bees with Machine Guns
$ bees up -s 2 -g default -z ap-northeast-1a -k aws-nrt-key -i ami-3e42b65f
New bees will use the "default" EC2 security group. Please note that port 22 (SSH) is not normally open on this group. You will need to use to the EC2 tools to open it before you will be able to attack.
Connecting to the hive.
Attempting to call up 2 bees.
Waiting for bees to load their machine guns...
.
Bee i-d73c2348 is ready for the attack
Bee i-d43c234b is ready for the attack.
The swarm has assembled 2 bees.
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Bees with Machine Guns
$ bees attack
테스트 대상 URL총 요청 개수동시 요청 개수테스트 수행 시간최소 RPS (Request Per Second)요청 VERB (GET, PUT, …)Hurl을 사용하는 경우 추가 설정
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Bees with Machine Guns
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Bees with Machine Guns
$ bees down
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
데모 2AWS Lambda 기반의 부하테스트툴 Goad 데모
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
GO + LOAD Goad (https://goad.io)
“Goad is an AWS Lambda powered, highly distributed,
load testing tool built in Go for the 2016 Gopher Gala.”
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
GO + LOAD Goad
var execFile = require("child_process").execFile;
exports.handler = function(event, context) {
child = execFile(event.file, event.args, function(error) {
context.done(error, "Process complete!");
});
child.stdout.on("data", console.log);
child.stderr.on("data", console.error);
};
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
GO + LOAD Goad
$ goad –c 30 –m GET –n 10000 –u http://wordpress….northeast.2.elb.amazonaws.com/wordpress/
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
GO + LOAD Goad
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
마지막으로 다시강조하자면 AWS를 이용한부하 테스트는 …
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
효율적인 비용충분하고 유연한
자원글로벌 리전
활용
쉽고 단순한아키텍처
구성 및 관리
감사합니다