GitHub Actions에서 N+1 쿼리를 자동으로 감지하고 PR에 코멘트 달기들어가며N+1 쿼리는 ORM을 사용하는 애플리케이션에서 가장 흔하게 발생하는 성능 문제입니다. 개발 환경에서는 데이터가 적어 눈에 띄지 않지만, 프로덕션에서는 심각한 성능 저하를 일으킵니다.이 글에서는 GitHub Actions CI 파이프라인에서 N+1 쿼리를 자동으로 감지하고, 코드 라인에 직접 리뷰 코멘트를 다는 방법을 소개합니다.목표PR에서 변경된 테스트 파일에서 발생한 N+1만 감지N+1이 발생한 정확한 테스트 위치에 리뷰 코멘트N+1이 수정되면 자동으로 코멘트 삭제rswag run_test! 실행 시에만 N+1 감지 활성화기존 접근 방식의 한계Prosopite만 사용할 때Prosopite는 N+1 쿼리를 감지하는 ..
Backend/RubyOnRails
a.b.c 조전까지만 해도 무심코 쓰던 코드입니다. A모델에 B가 있으니, 체인으로 c를 꺼내 쓰는 게 자연스럽게 느껴졌죠. 하지만 이 패턴은 Law of Demeter—최소 지식 원칙—을 정면으로 위배합니다. “내 옆집 문을 열어달라고 내 친구에게 부탁하지 말라”는 말처럼, 객체는 자신과 직접 관련된 이웃에게만 말을 걸어야 합니다. 그렇지 않으면 내부 구조가 외부에 노출돼 결합도가 치솟고, 작은 구조 변경이 연쇄 폭발로 이어집니다.이번 글에서는 운영 중인 rails 프로젝트를 예시로, Law of Demeter를 Rails에서 어떻게 지키고 있는지, delegate를 활용하면 어떤 장단점까지 정리해 봅니다.1. 문제는 어디서 시작됐나?A는 B과 1:1 관계를 맺고 있습니다. 외부에서 B의 c를 알고 싶..
들어가며최근 JupyterHub와 내부 시스템 간의 API 호출 과정에서 Timeout 설정값을 어떻게 잡는 게 적절할지 논의가 있었습니다. 단순히 “적당히 5초쯤?”으로 정하기보단, 실제 데이터 기반으로 최적값을 찾아보자는 접근을 해보았습니다.이 글에서는Timeout 값을 결정할 때 어떤 기준이 필요한지AWS Athena를 활용해 API 응답 시간을 분석하는 과정최종적으로 도출된 Timeout 설정값을 공유합니다.1️⃣ 문제 인식: “Timeout을 몇 초로 해야 할까?”해당 API는 주로 두 가지 요청을 처리합니다.토큰 발급유저 생성요청 자체는 많지 않지만, 호출 시점마다 응답이 지연될 때 전체 시스템에 영향을 줄 수 있습니다.특히 너무 긴 Timeout은 스레드 점유 시간 증가 → 전체 처리량 감소..
이걸 어떻게 진행하게 되었는가?Rails 프로젝트에서 Devise-Security (비밀번호 만료·재사용 방지 등 추가 보안 기능) 를 적용하려 했는데, 한국어(locale ko)가 존재하지 않는 걸 발견했어요. 서비스 전반에 한–영 메시지가 섞이면 사용자 경험이 깨지니 직접 번역해서 기여하기로 결정했습니다.진행 방법1. 레포지토리 Fork & 세팅# GitHub에서 Fork 후git clone git@github.com:my-id/devise-security.gitcd devise-securitygit checkout -b feature/i18n-ko2. 과거 PR 파헤치기PR [#240] “Add Spanish translations”를 참고했어요.동일한 패턴(로케일 파일 + 테스트 추가)을 재사용...
💡 원본 글 : https://blog.appsignal.com/2021/07/07/general-ruby-on-rails-problems-and-takeaways.html General Ruby on Rails Problems and Takeaways | AppSignal Blog In this last part of the Rails Patterns and Anti-patterns series, I'll be going over the most common problems I've encountered while building and shipping Ruby on Rails applications. blog.appsignal.com Ruby On Rails 패턴 및 안티 패턴 시리즈 마지막 파트에 ..
💡 원본글 : https://blog.appsignal.com/2021/04/14/ruby-on-rails-controller-patterns-and-anti-patterns.html Ruby on Rails Controller Patterns and Anti-patterns | AppSignal Blog In this part of the series on Rails patterns and anti-patterns, we are going to analyze the final part of the MVC (Model-View-Controller) design pattern — the Controller. blog.appsignal.com Ruby On Rails 패턴 및 안티 패턴 시리즈의 네 번째 편..
💡 원본글 : https://blog.appsignal.com/2021/02/10/ruby-on-rails-view-patterns-and-anti-patterns.html Ruby on Rails View Patterns and Anti-patterns | AppSignal Blog Rails views are sometimes amazing and fast, and at other times, they can have all sorts of issues. If you want to increase confidence over how you handle your views, then this blog post is for you. blog.appsignal.com Ruby On Rails 패턴과 안티패..
💡 원본글 : https://blog.appsignal.com/2020/11/18/rails-model-patterns-and-anti-patterns.html Ruby on Rails Model Patterns and Anti-patterns | AppSignal Blog If you're struggling with models, this blog post is for you. We will quickly go through the process of putting your models on a diet and finish strongly with some things to avoid when writing migrations. blog.appsignal.com Ruby on Rails 패턴 및 안티..
💡 원본 글: https://blog.appsignal.com/2020/08/05/introduction-to-ruby-on-rails-patterns-and-anti-patterns.html Introduction to Ruby on Rails Patterns and Anti-patterns | AppSignal Blog Dig into the basics of design patterns and anti-patterns. blog.appsignal.com Ruby On Rails 패턴 및 안티패턴 시리즈의 첫 번째 게시물에 오신 것을 환영합니다. 이 시리즈에서는 Rails 앱을 개발하는 동안 접할 수 있는 모든 종류의 패턴에 대해 자세히 살펴보겠습니다. 오늘 우리는 (디자인) 패턴이 무엇인지 보여주고..
NamedRoute의 _path vs _url 서론 RubyOnRails는 NamedRoute라는 쉽게 경로를 작성할 수 있는 방법을 제공합니다. # In config/routes.rb root to: 'blogs#index' # would recognize http://www.example.com/ as params = { controller: 'blogs', action: 'index' } # and provide these named routes root_url # => 'http://www.example.com/' root_path # => '/' routes를 작성할때 as라는 옵션을 제공해줘서 커스텀도 가능합니다. # In config/routes.rb get '/login', to: 'acc..