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アプリの画像配信最適化 - Imgproxyを活用したパフォーマンス改善事例
Search
muso
August 29, 2025
Programming
58
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Railsアプリの画像配信最適化 - Imgproxyを活用したパフォーマンス改善事例
muso
August 29, 2025
More Decks by muso
See All by muso
静的アセット配信をCDNに逃がすまで
nishiokashinji
0
31
k8sのシークレット管理をちょっとだけ楽にした話
nishiokashinji
0
170
ALB「証明書上限問題」からの脱却
nishiokashinji
0
470
Other Decks in Programming
See All in Programming
Workers Cache を知る
syumai
0
370
Long Living Tokens, Die, Die, Die! (or: The One Ring is Banned in Modern)
sylph01
0
340
個人開発者よ、Honoを使え(おじさんver)
tanahiro2010
2
270
現場と育てるRailsモデリング 〜Spreadsheetから始めたモデル設計〜
siroemk
2
730
なぜCTOを降りてFDEを選んだのか?〜なぜプロダクト企業がFDEで顧客の現場に踏み込むのか〜
gonta
1
220
Seven New Principles of Software Engineering
yegor256
0
130
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Kaigi on Rails 2026, Tokyo, Japan
marcoroth
2
300
phperだってパンチカードでコーディングしたい
o0h
PRO
0
370
作って学ぶSpring BootのAuto Configuration / JJUG Night Seminar 2026-10-19
rshindo
0
190
Domain-Driven Transformation
hschwentner
2
2.3k
パスワード再設定メールのURLについて知っておこう
uyuki234
0
170
re:Inventに行く前に知っておきたい現地参加のノウハウ
nokomoro3
0
440
Featured
See All Featured
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Designing Powerful Visuals for Engaging Learning
tmiket
1
610
For a Future-Friendly Web
brad_frost
184
10k
The Cult of Friendly URLs
andyhume
79
7k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.8k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
2
360
Reflections from 52 weeks, 52 projects
jeffersonlam
356
22k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
My Coaching Mixtape
mlcsv
0
360
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
300
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
600
Transcript
Rails アプリの画像配信最適化 Imgproxy を活用したパフォーマンス改善事例 2025/08/
[email protected]
自己紹介 活動名 無双(@nishi_okashi ) 普段のお仕事 Super Ramen Engineer
前提情報 BtoBtoC (超簡単に言えば)ホームページ作成サービス エンドユーザーの投稿機能があり、投稿機能一覧画面にはエンドユ ーザーが投稿した画像が多数表示される CarrierWave を利用
画像配信で問題となっていたこと CloudFront の配信コストが高額 画像表示に平均3-4 秒かかっていた 1 画像あたり1-10MB の転送でユーザーのパケットを圧迫
なぜ??
オリジナルを配信していた バリデーションは10MB
解決方法 画像サイズを減らす 表示域に合わせたリサイズを行う 品質を調整する フォーマットをWebP に統一
どうやって実施する?
CarrierWave のサムネイル生成 1. Uploader クラスでサムネイルを宣言 class MyUploader < CarrierWave::Uploader::Base version
:thumb do process :resize_to_fit => [300, 300] end end 2. 投稿時にオリジナルとサムネイルがアップロードされる 3. 2 の後に新しくサムネイルを設定した場合は #recreate_versions! で 作成
新しくサムネイルを設定して Rake タスク??
数が多くて現実的ではない…
動的リサイズ
ActiveStorage のVariant で解決! <%= image_tag @post.image.variant(resize:'300x300').processed %>
… したいが移行がちょっと大変そう
マネージドサービスを利用する? Imgix ImageFlux CloudFlare Images
コストが気になる…
Imgproxy(OSS) というものがありました
Imgproxy とは? Go 言語で実装されたプロキシサーバー Simplicity コードを書かなくていい Speed libvips を利用 Security
実寸サイズのチェック 署名による不正リクエストの防止
Simplicity 動かすだけならこれでオッケー docker pull ghcr.io/imgproxy/imgproxy:latest docker run -p 8080:8080 -it
ghcr.io/imgproxy/imgproxy:latest
Simplicity URL だけで画像変換ができる http://imgproxy.example.com/%signature/%processing_options/plain /%source_url@%extension
Simplicity 設定は環境変数のみ # 品質 IMGPROXY_QUALITY="80" # S3の利用設定 IMGPROXY_USE_S3="true" # 許可するS3バケット
IMGPROXY_ALLOWED_SOURCES="s3://my-bucket/"
Speed libvips はRails ガイドでも早いと紹介されている (とはいえもともとのソースはlibvips のwiki の情報) https://railsguides.jp/active_storage_overview.html ImageMagick は、libvips
に比べて知名度が高く普及も進んでいま す。しかしlibvips は10 倍高速かつメモリ消費も1/10 です。 “ “
Security (Simplicity と共通するが)受け入れる画像の制限を環境変数だけで 指定可能 # 受け入れる画像の最大解像度 IMGPROXY_MAX_SRC_RESOLUTION="50"
導入の結果 転送量: 1 枚あたり100KB 未満に削減(90% 以上削減) 表示速度: 1 秒未満に削減(70% 以上改善)
コスト: CloudFront 配信費を大幅削減
その他いいこと 簡単にサムネイルを作ることができるようになった(= デザイン変 更に柔軟に対応が可能になった) サムネイル画像をS3 に保存する必要がなくなった exif 情報を簡単に除去できる
まとめ 問題: オリジナル画像配信による高コスト・表示遅延・大容量転送 解決策: Imgproxy(OSS) による動的画像最適化 結果: 90% 以上の転送量削減、70% 以上の速度改善
メリット: 簡単導入・高速処理・柔軟な運用 Imgproxy は画像配信最適化の強力な選択肢です!
ありがとうございました