EC2에 스트레스 테스트를 했다.
사실 부하 테스트는 조금 더 정확하고 구체적으로 해야겠지만, 일단은 DB커넥션과 반응속도만 급하게 알고 싶어서,
일단 가볍게 할 수 있는 apache ab test를 활용하기로 했다.
공식문서
ab - Apache HTTP server benchmarking tool - Apache HTTP Server Version 2.4
ab - Apache HTTP server benchmarking tool ab is a tool for benchmarking your Apache Hypertext Transfer Protocol (HTTP) server. It is designed to give you an impression of how your current Apache installation performs. This especially shows you how many req
httpd.apache.org
스트레스를 줄 EC2가 필요하다.
EC2 하나를 판다.
sudo apt-get update
sudo apt-get install apache2-utils
스트레스를 받을 EC2에 top명령어를 쳐서 CPU및 연결 정보를 확인한다.
나는 EC2 인스턴스 2개에 요청을 분산 시키고 있어서, 둘 다 켜놨다.
ALB 모니터링을 활용해서 봐도 되겠지만, 이게 조금 더 직관적이라 이렇게 했다.
스트레스를 줄 EC2에 ab를 치면 활용할 수 있는 옵션들을 확인할 수 있다.
Options are:
-n requests Number of requests to perform
-c concurrency Number of multiple requests to make at a time
-t timelimit Seconds to max. to spend on benchmarking
This implies -n 50000
-s timeout Seconds to max. wait for each response
Default is 30 seconds
-b windowsize Size of TCP send/receive buffer, in bytes
-B address Address to bind to when making outgoing connections
-p postfile File containing data to POST. Remember also to set -T
-u putfile File containing data to PUT. Remember also to set -T
-T content-type Content-type header to use for POST/PUT data, eg.
'application/x-www-form-urlencoded'
Default is 'text/plain'
-v verbosity How much troubleshooting info to print
-w Print out results in HTML tables
-i Use HEAD instead of GET
-x attributes String to insert as table attributes
-y attributes String to insert as tr attributes
-z attributes String to insert as td or th attributes
-C attribute Add cookie, eg. 'Apache=1234'. (repeatable)
-H attribute Add Arbitrary header line, eg. 'Accept-Encoding: gzip'
Inserted after all normal header lines. (repeatable)
-A attribute Add Basic WWW Authentication, the attributes
are a colon separated username and password.
-P attribute Add Basic Proxy Authentication, the attributes
are a colon separated username and password.
-X proxy:port Proxyserver and port number to use
-V Print version number and exit
-k Use HTTP KeepAlive feature
-d Do not show percentiles served table.
-S Do not show confidence estimators and warnings.
-q Do not show progress when doing more than 150 requests
-l Accept variable document length (use this for dynamic pages)
-g filename Output collected data to gnuplot format file.
-e filename Output CSV file with percentages served
-r Don't exit on socket receive errors.
-m method Method name
-h Display usage information (this message)
-I Disable TLS Server Name Indication (SNI) extension
-Z ciphersuite Specify SSL/TLS cipher suite (See openssl ciphers)
-f protocol Specify SSL/TLS protocol
(SSL2, TLS1, TLS1.1, TLS1.2 or ALL)
-n, -c를 활용해서 요청 수를 조절 할 수 있겠다.
아래와 같은 경우 1000개의 요청을 100명이 보내는 거다.
ab -n 1000 -c 100 https:요청url/
즉 문과식 계산을 해보자면.. 초당 100개씩 쏜당.
쏘면 이런 식으로 응답이 온다. 문과식 계산 만세
나는 헤더에 로그인 정보를 실어서 요청하고 싶기에, -h도 추가했다.
사용법은 간단한다.
-h "키 : 값"
그럼 직접 스트레스를 주면서 ec2의 cpu상태 등등을 확인하며 테스트하면 되겠다.
'Back > Server' 카테고리의 다른 글
[API] H?D 교육 스킵 (0) | 2023.06.27 |
---|---|
[Ubuntu] firebase-admin - error:25066067:DSO support routines:dlfcn_load:could not load the shared library (0) | 2022.06.12 |
[Aws RDS Aurora Serverless MySQL] 외부 접속 (0) | 2021.11.17 |
AWS WAF Custom Rule 간단 예제 (2) | 2021.11.10 |
[MySQL] Full Text Search Aws Aurora (0) | 2021.11.02 |