Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Railsアプリのよくある パフォーマンス問題の種
Search
naohiro-t
January 23, 2020
Programming
220
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Railsアプリのよくある パフォーマンス問題の種
naohiro-t
January 23, 2020
Transcript
40 slides
Application Monitoring for Ruby, Elixir, Python, PHP Railsアプリのよくある パフォーマンス問題の種 Naohiro
Takahashi
[email protected]
自己紹介 Naohiro Takahashi
[email protected]
Software Developer/Sales Engineer at Scout @naohiro_tt
• N+1 • count vs size • Memory Bloat 種
N+1の影響力知っていますか? N+1
N+1
joins? includes? preload? eager_load? 1. 絞り込みしたいだけなら、joins 2. 関連テーブルのデータにアクセスするなら includesから始めてみる 3.
SQLが2個発行されている場合には、eager_load とperformanceを比べる
改善してみた
改善してみた
改善してみた
count vs size 1. countは毎回クエリを発行する 2. sizeは一度読み込んでいたものに対しては、 collection のlengthを取得するのみ
count vs size
count vs size
count vs size
count vs size
count vs size
・・・
Memory bloat
Heroku R14
Railsのmemory bloatについて知っておくべきこと • メモリ使用量が自然に減少することはない • ヘビーユーザーが原因になっていることが多い • アロケーションの最大値に注目 • アロケーションとメモリ使用量は、必ずしも相関しない
• アプリスタート直後は、メモリ使用量が増加しやすい
Memory: Memory Bloat Insights
Memory: Memory Bloat Insights
Memory: Memory Bloat Insights
レスポンススピードを改善することにより、 CVR向上、UXの向上が見込めます。 ▪ ユーザーの47%はウェブサイトが2秒以内にロードすることを基 本と考えている ▪ 読み込み時間が3秒以上の場合、40%のユーザーは離脱する ▪ ページ読み込みが1秒遅い場合、7%CVRが減少する ▪
ユーザーの52%はページの読み込みが早いと、よりエンゲージ メントが高まる傾向にある ▪ ユーザーの72%はUXが良くないと感じたECは次回以降積極的 に使わない傾向にある *米国でのレスポンスタイムによるECサイトでの影響の事例 APMの必要性
Doggoに聞く、Scoutの優位性 - その1 UI・UXが、初めてでも直感的に使いやすくなっております
1. レスポンスタイムがすぐに分かる 3. ボトルネックの原因をその場で把握 2. ドラッグドロップで範囲選択 APMは一般的にレスポンスタイムやリクエスト数を表示します。 Scoutのダッシュボードではページを遷移すること なく、任意の期間をソートし特定のレスポンス遅延等を引き起こした原因の大枠を把握することができます。 直感的なUI・UX
Doggoに聞く、Scoutの優位性 - その2 Insightsにより、パフォーマンスボトルネックの明確になっ ております。
N+1 クエリが発生しているリクエストを自動的に検出、表示します。 Insights: N+1
アプリケーションの中で、特に遅い DBクエリを自動検出、表示します。 Insights: Slow Query
メモリーブロート問題を自動検出、表示します。 Insights: Memory Bloat
Doggoに聞く、Scoutの優位性 - その3 AutoInstrumentsによって、Controller一行ごとを自動的 に計測しております(現在、Railsのみ対応)
他社APMでは、モニタリング用のコードを追加しないと計測できない詳細な情報 (現在のところ、 Controller一行ごとの時間)、Scoutが自動的に計測します Auto Instruments 1. Sleep::runが5秒使用
Doggoに聞く、Scoutの優位性 - その4 Github Integrationによりソースコードとの紐付けが可能 となっております
1. ボトルネックの原因のコードを表示 2. コードの作者を表示、対応の依頼が可能 3. チームで共有可能 Scoutは、頻繁に使用されるアクション (DBクエリ、HTTPリクエスト、テンプレートレンダリング等 )を始め、他にも多 くのアクションのトラッキングに長けています。
Scoutのトレースは、ボトルネックとなるソースコードと紐付いている ので、実際の原因特定までの時間を大幅に削減することができます。 ソースコードとの紐付けが可能
Doggoに聞く、Scoutの優位性 - その5 開発環境では、無料でScoutのDevTraceを使用可能に なっております。
開発環境でも、手軽に無料でパフォーマンス改善可能 DevTrace
KeyをScoutから取得し、 環境変数、又は ファイルから設定 言語別のエージェントを インストール gem “scout_apm” アプリを起動! (モニタリング開始) 1
2 3 導入方法
ユーザーの声
Doggoに聞く、Scoutの優位性 - ラスト 柔軟な価格設定になっております
None
14日間無料トライアル実施中! Naohiro Takahashi Developer/Sales Engineer in JP
[email protected]
More Decks by naohiro-t
See All by naohiro-t
Fast JSON API - How fast is it really?
naohiro_t
1
450
Other Decks in Programming
See All in Programming
Getting Started with Vibe Coding
miccheng
0
250
Enforcing Your Architecture with Unit Tests in the AI Era (Swift Connection X)
steliosf
PRO
1
200
SODA - FACT BOOK(EN)
sodainc
1
300
Going Full Circle with Virtual Graphs and Relational Databases
michaelsimons
1
120
特急いなほ as a Workflow / 20261107jaws-festa-2026-akita-lt
kasacchiful
PRO
0
110
Math.sumPreciseから学ぶ、ECMAScript仕様の数値の種類
syumai
0
1.2k
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
440
初学者向け 分散トレーシングとDatadog
mtaka1222
0
110
JavaScriptはシングルバイナリの夢を見るか / Does JavaScript Dream of a Single Binary?
ssssota
1
1.1k
Agentic AI with the Power of Jakarta EE
ivargrimstad
0
230
LLM 101
dalinaum
0
550
Claude Codeのおかげでやりたいことがやれるようになったんだよォー!
sms_tech
0
190
Featured
See All Featured
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
490
The Spectacular Lies of Maps
axbom
PRO
1
1.2k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.4k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.3k
Docker and Python
trallard
47
4.3k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
1
320
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.2k
My Coaching Mixtape
mlcsv
0
400
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
1
310
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Fireside Chat
paigeccino
43
4.1k
Marketing to machines
jonoalderson
1
6k