-
내 서버는 얼마나 버틸 수 있는가운영 중인 서비스/Coconut. 2024. 2. 15. 12:34
현재 개발 환경에서는 EC2 프리티어를 사용하고 있고 도커 컨터이너에 spring boot 서버를 띄워 둔 상태입니다.
간간히 서버가 cpu 사용율이 올라가면서 종료가 되는데, 같이 일하는 프론트엔드 개발자들에게도 불편함을 주고 있고 실제 운영서버에서도 동일한 현상이 발생할 수 있기 때문에 대비책을 세워보려고 합니다.
가장 먼저 해보려는 것은 서버가 다운되는 케이스를 재현하는 것 입니다.
apache bench를 사용해서 서버 부하량을 서서히 올려보겠습니다.
Try1 - 요청 1건
먼저 1개의 요청을 보내보겠습니다.
$ ab -n 1 -c 1 http://ec2-3-36-204-107.ap-northeast-2.compute.amazonaws.com/api/v1/post
예상대로 서버 리소스 사용률 그래프에 별다른 변화가 보이지 않습니다.
1건을 보내면 cpu 0.8% 정도가 사용되는 것 같습니다.
Try2 - 요청 10건
이번에는 10개의 요청을 동시에 보내 보겠습니다.
$ ab -n 10 -c 10 http://ec2-3-36-204-107.ap-northeast-2.compute.amazonaws.com/api/v1/post
10건의 요청 정도로는 의미있는 차이를 보이는 것 같지 않습니다.
Try3 - 요청 10,000건
그러면 이번에는 10,000건의 요청을 100명의 유저가 요청하는 상황을 가정해보겠습니다.
$ ab -n 10000 -c 100 http://ec2-3-36-204-107.ap-northeast-2.compute.amazonaws.com/api/v1/post
10,000 요청을 다 완료하지 못하고 마무리가 되었습니다. 타임아웃 숫자를 늘려봐야겠습니다.
ec2의 cpu는 그래도 최대 40%를 사용하지 않는 선에서 마무리가 된 것 같습니다.
보통 종료될 때는 80% 가까운 사용율을 보이고 종료되는데 10,000건의 요청으로는 어림 없는 것 같습니다.
RDS의 모니터링 지표를 보았을 때. cpu가 48% 정도 사용되는 것으로 확인이 됩니다.
서버 사용률이 올라가는 이슈는 많은 요청에 있는 것이 아닌 것 같다고 보아야될 것 같습니다.
서버 측 보다는 오히려 디비 사용률이 너무 올라가는 것이 아닌가 하는 생각이 듭니다.
부하 테스트는 이정도로 마무리하고 이상이 있을 때 알림을 받을 수 있도록 설정해보아야겠습니다.
감사합니다.
'운영 중인 서비스 > Coconut.' 카테고리의 다른 글
문제 해결을 위한 증거자료 수집하기 (feat.로그) (0) 2024.02.17 CloudWatch를 사용해서 Discord에서 EC2 상태 알림 받기 (0) 2024.02.16 조회수 변경 시 발생하는 레이스 컨디션과 해결 방법 (1) 2024.02.02 String으로 사용되던 데이터 enum으로 상수처리 (0) 2024.01.30 테스트를 쓰면서 만난 좋지 않은 Util 클래스와 의존성관리 (0) 2024.01.25