More Related Content
Similar to AWS와 부하테스트의 절묘한 만남 :: 김무현 솔루션즈 아키텍트 :: Gaming on AWS 2016
Similar to AWS와 부하테스트의 절묘한 만남 :: 김무현 솔루션즈 아키텍트 :: Gaming on AWS 2016 (20)
More from Amazon Web Services Korea
More from Amazon Web Services Korea (20)
AWS와 부하테스트의 절묘한 만남 :: 김무현 솔루션즈 아키텍트 :: Gaming on AWS 2016
- 2. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
런치 준비
완료?
- 3. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
- 4. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
부하 테스트 사전 수행
아니면
서비스 런치 후
초조하게 기도하기?
- 5. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
부하 테스트에 대해서
살펴봅시다.
- 6. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
부하 테스트란 무엇일까요?
소프트웨어 시스템 또는 컴퓨팅 장치에 요청을 보내고
응답을 측정하는 테스트 방법
부하 테스트를 통해서 …
• 현재 서비스 구성의 제한(limit)을 찾기
• 원하는 부하를 수용할 수 있게끔 구성되었는지 확인
• 병목 지점을 찾고 병목 현상을 제거
- 7. © 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
- 8. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
부하 테스트 수행전에 고려해야할 내용들
• 충분한 테스트용 서버 자원 확보
• 테스트 시, 블랙박스 혹은 격리된 환경 제어
• 글로벌 기반의 부하 생성
• 높은 비용과 불규칙적인 사용성에 대한 주의
• 높은 아키텍처 복잡성에 대한 주의
- 9. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS와 부하 테스트의
조합은 어떨까요?
- 10. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS 클라우드 기반의 부하 테스트의 장점
- 11. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS 클라우드 기반의 부하 테스트의 장점
효율적인 비용 • 테스트 조건에 맞는 인스턴스 사용
• 워밍업 테스트에는 작은 인스턴스 사용
• 테스트 종료 후, 자원 반환
- 12. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS 클라우드 기반의 부하 테스트의 장점
충분하고 유연한
자원
• 필요한 규모의 테스트 자원 확보 가능
• 오토스케일팅을 통한 부하 테스트시 자원 자동 증가 및
감소
- 13. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS 클라우드 기반의 부하 테스트의 장점
글로벌 리전
활용
• 전 세계 리전을 활용한 부하 테스트 수행
- 14. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS 클라우드 기반의 부하 테스트의 장점
쉽고 단순한
아키텍처
구성 및 관리
• CloudFormation을 이용한 동일한 운영, 테스트 환경의
손쉬운 구성
• 관리형 서비스, Serverless 서비스를 이용한 부하 테스트
환경 운영 간소화 및 단순화
- 15. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
부하 테스트 수행은 어떻게
하는지 알아봅시다
- 16. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
단계별로 수행하는 부하 테스트
• 비결합(Loosely Coupled)된 개별 컴포넌트에 대한 부하
테스트
• 내부 서비스에 대한 부하 테스트
• 외부 서비스에 대한 부하 테스트
• 전체 스택에 대해 부하 테스트
- 17. © 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 부하 확인
- 18. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• DirectConnect 또는
VPN 성능 검증
• AWS에 Cache 또는
Proxy cache가
필요한지 확인
• IP 주소가 겹치지
않도록
데이터센터에 있는 서비스 테스트
- 19. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
외부 서비스에 대한 부하 테스트
External
APIs
Internet
Load Test
Scripts
Region 1
Metrics
Collection &
Graphing
Load
GeneratorsLoad Test
Scripts
Region 2
Metrics
Collection &
Graphing
Load
Generators
Load Test
Scripts
Region 3
Metrics
Collection &
Graphing
Load
Generators
부하 테스트
수행 전에
외부 서비스에
공지가
필요한지
확인하자
- 20. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
전체 스택에 대해 부하 테스트
• 전체 게임 플레이 세션을 시뮬레이션
• 다양한 지역에서 테스트 수행
• 전체 인프라에 대한 전체적인 뷰
• 파이프라인상에서 병목 확인
• 오토-스케일링 정책을 세우는데 도움을 줌
- 21. © 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
- 22. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
전체 스택에 대해 부하 테스트 어떻게 이뤄지나요?
Developers
Developers
Developers
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
- 23. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
3-티어에 대한 부하 테스트
전략
- 24. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
3-티어에 대한 부하 테스트 수행
1. 최초 ‘WEB’ 을 출력하는 웹
페이지를 대상으로 동시
연결성에 대한 테스트 수행
2. 결과 평가
3. 최적화 진행
- 25. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
3-티어에 대한 부하 테스트 수행
1. 웹 서버를 통해 애플리케이션
서버에서 넘겨 받은
‘APPLICATION’ 을 출력하는
웹 페이지를 대상으로 동시
연결성에 대한 테스트 수행
2. 결과 평가
3. 최적화 진행
- 26. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
3-티어에 대한 부하 테스트 수행
1. 데이터베이스에서 최소한의
쿼리 결과를 전달 받아
출력하는 웹 페이지를
대상으로 동시 연결성에 대한
테스트 수행
2. 결과 평가
3. 최적화 진행
- 27. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
3-티어에 대한 부하 테스트 수행
1. 3-tier 스택 전체를 대상으로
애플리케이션 로직이 적용된
페이지에 동시 연결성에 대한
테스트 수행
2. 결과 평가
3. 최적화 진행
- 28. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
3-티어에 대한 부하 테스트 수행
1. 4번을 기반으로 다양한
시나리오를 지정하여 테스트
수행
2. (얻고자 하는 지표 기준에
대해서) 결과 평과
3. 최적화 진행
시나리오별 테스트를 해야죠!
- 29. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
각 레이어별로는 어떤 것을
고려해야할까요?
- 30. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
각 레이어별 고려사항
• 네트워크 용량 확인
• 부하 생성 클라이언트
• 로드 밸런싱
(Elastic Load Balancing)
• 서버 인스턴스
• 어플리케이션 서버
• 어플리케이션
• 데이터베이스
아웃바운드 연결에 예상되는 최대
부하를 처리가능한지?
• EC2 인스턴스 타입 – Enhanced
Networking
• VPN 네트워크 성능 등
- 31. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
각 레이어별 고려사항
• 네트워크 용량 확인
• 부하 생성 클라이언트
• 로드 밸런싱
(Elastic Load Balancing)
• 서버 인스턴스
• 어플리케이션 서버
• 어플리케이션
• 데이터베이스
• 원하는 부하양을 생성할 수 있는
충분한 인스턴스 확보
• 부하 생성 클라이언트 특징
확인필요
- 32. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
각 레이어별 고려사항
• 네트워크 용량 확인
• 부하 생성 클라이언트
• 로드 밸런싱
(Elastic Load Balancing)
• 서버 인스턴스
• 어플리케이션 서버
• 어플리케이션
• 데이터베이스
• Backend / Target 인스턴스들이
요구량 증가에 신속하게 대응
가능한지 (Auto Scaling)
• 급격한 부하 증가 시나리오인 경우,
사전 ELB 확장
• Keep-Alive 설정을 통한 불필요한
연결 재수립 방지
- 33. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
각 레이어별 고려사항
• 네트워크 용량 확인
• 부하 생성 클라이언트
• 로드 밸런싱
(Elastic Load Balancing)
• 서버 인스턴스
• 어플리케이션 서버
• 어플리케이션
• 데이터베이스
• 서버 성능 최적화
• Open Files Limit
- 34. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
각 레이어별 고려사항
• 네트워크 용량 확인
• 부하 생성 클라이언트
• 로드 밸런싱
(Elastic Load Balancing)
• 서버 인스턴스
• 어플리케이션 서버
• 어플리케이션
• 데이터베이스
• Thread 기반인 경우 Thread Pool
크기가 적당한지
• Event 기반 비동기 형태의
어플리케이션 서버 사용
- 35. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
각 레이어별 고려사항
• 네트워크 용량 확인
• 부하 생성 클라이언트
• 로드 밸런싱
(Elastic Load Balancing)
• 서버 인스턴스
• 어플리케이션 서버
• 어플리케이션
• 데이터베이스
어플리케이션 코드 – Unit 테스트, Lint
• 잘못된 방식의 프레임워크, API
사용
• Blocking 코드
• 불필요한 연산 또는 테스트 코드
어플리케이션 프레임워크
• 웹 프레임워크나 ORM(Object-
relational mapping) 라이브러리
오류
- 36. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
각 레이어별 고려사항
• 네트워크 용량 확인
• 부하 생성 클라이언트
• 로드 밸런싱
(Elastic Load Balancing)
• 서버 인스턴스
• 어플리케이션 서버
• 어플리케이션
• 데이터베이스
• CPU 사용률과 응답 시간 확인
• 설정에 따라 더 요구되는 자원이
있는지 점검
• 메모리 사용률 확인
- 37. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
꼭 알아야할 팁
- 38. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
부하테스트 시 유용한 팁 모음
• 가능한 모든 것을 자동화
• 로그 기록과 확인
• 적절한 인스턴스의 선택
• 비용 최소화
• 다양한 도구와 서비스의 복합적 활용
- 39. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
그러면 부하 테스트를 위한
도구들은 어떤것이 있을까요
- 40. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
부하 테스트 도구들
EC2
설치형
서비스형
AWS
활용형
- 41. © 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 부하 테스트
• 초당 일정한 속도록 특정 수치의 요청을 지속
- 42. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
부하 테스트 도구들
EC2
설치형
- 43. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
부하 테스트 도구들
RedLine13
• AWS Advanced Technology Partner
• 부하 테스트 수행 서비스 제공
• AWS IAM 계정을 이용한 Agent 설치
• 스팟 인스턴스 활용을 통한 비용 절감
• JMeter, Gatling, Python, PHP 및 NodeJS 지원
서비스형
- 44. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
부하 테스트 도구들
RedLine13
서비스형
- 45. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
부하 테스트 도구들
Loader.io
• 클라우드 기반의 부하테스트 서비스
• 대상 서버 지정, 원하는 동시성 지정 등
• 테스트 리플레이 가능
서비스형
출처: loader.io
- 46. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
부하 테스트 도구들
Bees with Machine Guns
• EC2 인스턴스를 지정한 개수만큼 생성해서 부하 테스트 수행
• 스팟 인스턴스 활용 옵션
• ApacheBench 기반 (hurl 사용 가능)
AWS
활용형
- 47. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
부하 테스트 도구들
Goad
• AWS Lambda를 이용한 분산 부하 테스트
• 대상 URL에 부하 테스트 수행 후, AWS SQS를 통한 결과 취합
AWS
활용형
Amazon SQS
$ goad λ 수행
- 48. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
부하 테스트 도구 선택은?
도구 명 활용 방법
JMeter 웹 애플리케이션 내에서 사용자의 행동 흐름에 대해 부하 테스트를 하고 싶을 때
Tsung API 가 수용할 수 있는 최대치의 부하를 알고 싶을 때
Vegeta
어떤 API 에 대해 초당 특정 수치의 요청이 지속될 경우 발생하는 상황을 파악하고
싶을 때
Goad 부하 생성 클라이언트 구성을 포함한 부하 테스트 관련 인프라 구성을 피하고 싶을 때
RedLine13
JMeter 로 테스트 플랜을 작성하여 활용을 원하지만, 비용을 최소화 하고 싶고 사용한
만큼만 비용이 발생하길 원할 때
Blazemeter
높은 동시성을 위해 JMeter 의 Remote Testing 기능을 활용하고 싶지만, 테스트 플랜
작성에 집중하고, 부하 테스트 관련 인프라 구성은 하고 싶지 않을 때
Loader.io
부하 테스트 관련 인프라 구성을 하고 싶지 않고, Tsung 과 비슷한 목적으로 사용하고
싶을 때
- 49. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
데모 1
AWS EC2 자동 구성
Bees with Machine Guns!
- 50. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Bees with Machine Guns
$ bees up $ bees attack $ bees down
- 51. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Bees with Machine Guns
$ bees up
EC2 on-demand 또는 Spot
리전 및 가용영역
인스턴스 타입
인스턴스 개수
AMI
서브넷
보안 그룹
SSH 키
- 52. © 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.
- 53. © 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을 사용하는 경우 추가 설정
- 54. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Bees with Machine Guns
- 55. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Bees with Machine Guns
$ bees down
- 56. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
데모 2
AWS Lambda 기반의 부하
테스트툴 Goad 데모
- 57. © 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.”
- 58. © 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);
};
- 59. © 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/
- 60. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
GO + LOAD Goad
- 61. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
마지막으로 다시
강조하자면 AWS를 이용한
부하 테스트는 …
- 62. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
효율적인 비용
충분하고 유연한
자원
글로벌 리전
활용
쉽고 단순한
아키텍처
구성 및 관리