분류 전체보기
-
N + 1 정복하기 <4. @BatchSize>프레임워크/Spring Boot 2024. 2. 21. 03:40
시리즈1. https://iwsaitw.tistory.com/entry/N-1-정복하기 시리즈2. https://iwsaitw.tistory.com/entry/N-1-정복하기-2-FetchTypeEAGER 시리즈3. https://iwsaitw.tistory.com/entry/N-1-정복하기-3-Fetch-Join (소스코드: https://github.com/blog-example/-JPA-N_Plus_1) ORM을 사용하면 만나는 흔한 이슈 중 하나인 N + 1 ! 명확하게 설명할 수 있을 정도로 머리속에 집어넣어보겠습니다. 이번 글에서는 @BatchSize를 활용해서 N + 1을 해결하는 과정을 살펴보겠습니다. 이글은 3번 글에서 이어집니다. 3번 글을 보고 오시면 이해에 도움이 될 것 같습니다! ..
-
N + 1 정복하기 <3. Fetch Join>프레임워크/Spring Boot 2024. 2. 21. 02:57
시리즈1. https://iwsaitw.tistory.com/entry/N-1-정복하기 시리즈2. https://iwsaitw.tistory.com/entry/N-1-정복하기-2-FetchTypeEAGER (소스코드: https://github.com/blog-example/-JPA-N_Plus_1) ORM을 사용하면 만나는 흔한 이슈 중 하나인 N + 1 ! 명확하게 설명할 수 있을 정도로 머리속에 집어넣어보겠습니다. 이번 글에서는 fetch join을 활용해서 N + 1을 해결하는 과정을 살펴보겠습니다. 1. JPQL? Fetch Join? Fetch Join 을 이야기 하기에 앞서서 JPQL을 먼저 이야기할 필요가 있습니다. gpt가 뭐라고 정의하는지 한 번 보겠습니다. JPQL은 개발자가 원하는 ..
-
N + 1 정복하기 <2. FetchType.EAGER>프레임워크/Spring Boot 2024. 2. 20. 18:09
(소스코드: https://github.com/blog-example/-JPA-N_Plus_1) ORM을 사용하면 만나는 흔한 이슈 중 하나인 N + 1 ! 명확하게 설명할 수 있을 정도로 머리속에 집어넣어보겠습니다. 지난글에서 N + 1이 무엇이고 왜 발생하고 어떤 코드에서 발생하는지 살펴보았습니다. 이번 글에서는 FetchType.EAGER와 N + 1의 관계에 대해서 살펴보겠습니다. [글의 진행] 1. FetchType.EAGER 적용하기 2. FetchType.EAGER 공식문서 확인하기 3. FetchType.EAGER 실행확인하기 4. FetchType.EAGER의 또 다른 동작 지난 글에서 연관관계가 있는 엔티티 로딩시 성능 최적화를 위해서 FetchType.LAZY를 사용하면서 N + 1 ..
-
N + 1 정복하기 <1. N + 1?>프레임워크/Spring Boot 2024. 2. 20. 16:13
(소스코드: https://github.com/blog-example/-JPA-N_Plus_1) ORM을 사용하면 만나는 흔한 이슈 중 하나인 N + 1 ! 명확하게 설명할 수 있을 정도로 머리속에 집어넣어보겠습니다. 이번글에서는 N + 1이 무엇이고 왜 발생하고 어떤 코드에서 발생하는지 살펴보겠습니다. 1. N + 1이 무엇? 2. 프로젝트 세팅하기 3. N + 1 왜 발생하는가? 1. N + 1 이 무엇? gpt는 n + 1 이슈를 무엇이라고 정의하는지 살펴보겠습니다. 명쾌하게 잘 정리해준 것 같습니다! 면접 때 질문을 받으면 이 정도 내용으로 답변을 하면 좋겠다는 생각이 듭니다. # 데이터베이스 쿼리 최적화 이슈 # 한 번의 쿼리로 N개의 엔티티를 가져오지만 해당 엔티티에 접근할 때 추가로 N번의 ..
-
문제 해결을 위한 증거자료 수집하기 (feat.로그)운영 중인 서비스/Coconut. 2024. 2. 17. 17:27
aws에서 제공하는 프리티어 EC2를 사용해서 개발 환경을 운영하고 있습니다. 도커 컨테이너 위에 Spring 서버가 떠 있는데, 종종 서버가 종료되는 상황이 발생해서 로그를 남겨보려고 합니다. 이전 글에서는 인프라 레벨에서 문제 확인을 위해 알림을 세팅했다면, 이번 글에서는 제 코드 레벨에서 문제가 있는지 확인을 위해서 로그를 남기는 방법을 찾아보겠습니다. (이전글: https://iwsaitw.tistory.com/entry/Discord를-사용해서-간단한-EC2-알림-받기) 1. 로그 파일 생성 spring-boot-start-web을 의존성으로 사용하면 별다른 설정 없이도 Logback을 사용해서 콘솔창에서 로그를 확인할 수 있습니다. @RequiredArgsConstructor @Service ..
-
CloudWatch를 사용해서 Discord에서 EC2 상태 알림 받기운영 중인 서비스/Coconut. 2024. 2. 16. 20:43
aws에서 제공하는 프리티어 EC2를 사용해서 개발 환경을 운영하고 있습니다. 도커 컨테이너 위에 Spring 서버가 떠 있는데, 종종 서버가 종료되는 상황이 발생해서 알림을 받아보려고 합니다. 지금 이슈가 발생하고 있는 경우는 크게 2가지 입니다. 1. cpu 사용율이 올라가면서 도커 컨테이너 중단됨 2. cpu 사용율이 올라가면서 'Instance status checks' 가 fail 됨 각 케이스에 맞는 알림을 discord에서 받아볼 수 있도록 설정을 해보겠습니다. 1. 알림을 보내는 Lamda 함수 작성 Lamda 서비스를 이번에 처음 사용해봤는데, 간단하게 이벤트 핸들러에 전달되는 콜백 함수 정도로 생각하면 좋을 것 같습니다. 실행될 메소드와 실행환경을 다른 서비스에 등록하면 원하는 이벤트에..
-
EC2 RHEL 9.3에서 htop 설치하기인프라/linux 2024. 2. 15. 22:38
부하 테스트를 위해 htop을 설치하던 중 고생을 하여 기록으로 남깁니다. 아래의 명령어로 설치가 안되는 경우에 사용 가능합니다. $ sudo yum install epel-release // 설치 안됨 // Updating Subscription Management repositories. // Unable to read consumer identity // This system is not registered with an entitlement server. You can use subscription-manager to register. 수동으로 설치 하는 과정입니다. $ sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-..
-
내 서버는 얼마나 버틸 수 있는가운영 중인 서비스/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 예상대로 서버 리소스 사용률 그래프에..