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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
AIで開発が速くなった先で、開発チームは何を目指すか
shihochan
1
1.6k
Event is what happens
moro
2
860
パスワード再設定メールのURLについて知っておこう
uyuki234
0
160
iOS 27でニュースアプリはどう変わる!? 〜日経電子版の新機能対応と、開発事例から〜
lynnswap
7
13k
自サークルのIdPからログアウトできるようになるまで
taiseiue
1
140
Atomic Design, Enforced: Scaling Mobile Design Systems (next.app devCon / droidCon Berlin 2026)
steliosf
PRO
0
170
S3 TablesのIcebergデータに、AIエージェントからアクセスしてみた / 20261016developersio2026joetsu-accessing-iceberg-in-s3tables-via-agent
kasacchiful
PRO
0
170
Unity6 URPによる海底をテーマにしたVJシステムの解説 | Unity Shader 完全に理解した 勉強会
gam0022
0
370
sbt 2.0: takeoff
eed3si9n
0
160
AIに “答え“を書かせるのを やめてみた
___akari11
0
120
golang-bob.pdf
iwatsukayura
0
130
設計次第でAIコードの読む量は減らせる / designing-for-code-reading
minodriven
35
17k
Featured
See All Featured
The Invisible Side of Design
smashingmag
301
52k
GitHub's CSS Performance
jonrohan
1033
470k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
1k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
730
Technical Leadership for Architectural Decision Making
baasie
3
600
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
The Pragmatic Product Professional
lauravandoore
37
7.5k
Producing Creativity
orderedlist
PRO
348
41k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
320
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.4k
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
ラッコキーワード サービス紹介資料
rakko
1
5.4M
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 は画像配信最適化の強力な選択肢です!
ありがとうございました