redis 도입의 장점
- 모든 데이터를 메모리 내에 저장하고 관리
- 디스크 기반 데이터베이스 시스템 보다 읽기/쓰기 속도가 빠름
- 대량의 읽기/쓰기 연산이 플요한 어플리케이션에서 응답 시간을 단축 시켜줌
단일 글을 조회 시 db로만 호출 vs redis를 활용하여 조회
먼저 성능 차이를 확인 하기 위한 툴 apache Jmeter, Locust 중에 Locust를 사용했다.
Locust : https://locust.io/
Locust.io
An open source load testing tool. Define user behaviour with Python code, and swarm your system with millions of simultaneous users.
locust.io
Loucst 세팅
파이썬을 설치 해준 후 loucst 를 설치해줬다.
npm install locust
locust를 설치 후 홈페이지에 있는 documents를 참고하여 테스트를 진행했다.
https://docs.locust.io/en/stable/quickstart.html
Your first test — Locust 0.1.dev129 documentation
The following screenshots show what it might look like when running this test using 50 concurrent users, with a ramp up rate of 1 users/s Note Interpreting performance test results is quite complex (and mostly out of scope for this manual), but if your gra
docs.locust.io
먼저 파일 이름은 무조건 locustfile.py 으로 만들어야 한다.
from locust import HttpUser, task
class HelloWorldUser(HttpUser):
@task
def hello_world(self):
self.client.get("도메인을 제외한 경로")
이렇게 파일을 생성 후 터미널에 locust를 치면 실행된다.
실행하면
차례대로 사용자 수 , 매초 몇명의 새로운 가상 사용자를 시작, 서버 호스트 , 몇초분시 동안 돌릴지 확인
Db만 사용했을 때
redis 사용했을 때
같은 시간 내에 요청처리량 35% 증가
평균 요청 시간 26% 감소
redis를 사용하여 35% 성능 개선을 이뤄냈다.
'[for Rest 프로젝트]' 카테고리의 다른 글
Spring - redis 적용하기 (1) | 2024.03.26 |
---|---|
Spring - Swagger UI 적용하기 (0) | 2024.03.10 |
Spring - 이메일 인증 구현하기 (0) | 2024.03.07 |
react - [useState] (0) | 2024.02.04 |
LazyLoading (1) | 2024.01.30 |