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
60
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
35
k8sのシークレット管理をちょっとだけ楽にした話
nishiokashinji
0
170
ALB「証明書上限問題」からの脱却
nishiokashinji
0
480
Other Decks in Programming
See All in Programming
Spec-Driven Development - Why Vaadin Is the Perfect Fit
simas
PRO
0
220
선언형 햅틱 라이브러리 진동을 소개합니다
l2hyunwoo
1
280
Coding with AI: How to trust the storyteller (AWS Community Day Adria, Ljubljana 2026)
slobodan
0
140
3回つくってわかった、 定期実行ジョブ基盤の本質情報
takai
4
3.7k
複数ドメインを一つのアプリに統合するFlutterの設計と運用_FlutterKaigi2026登壇資料(須永高弘)
takahirosunaga
0
140
Lambda durable functionsでHuman in the Loopを楽に…楽に……
har1101
2
260
プロジェクトコードをキレイキレイしよう!暗黙的な参照を読み解く静的解析
ostk0069
0
200
[Dev Group Paris Octobre 26] Agentforce, SIforce, Claudeforce, Slackbot… on s'y retrouve ?
nabondance
0
130
Enforcing Your Architecture with Unit Tests in the AI Era (Swift Connection X)
steliosf
PRO
1
120
GraphQL の onError と Nullability のこれから
quramy
0
200
조합이폭발하는디자인시스템이걸눈으로도테스트하라고요
giljongyu
0
710
React Native에 현대적인 빌드 도구 더하기: Rollipop 구현기
leegeunhyeok
0
180
Featured
See All Featured
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
330
Testing 201, or: Great Expectations
jmmastey
46
8.4k
Are puppies a ranking factor?
jonoalderson
2
4.1k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
1
600
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
970
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
Done Done
chrislema
187
17k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
4
4.4k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.2k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
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 は画像配信最適化の強力な選択肢です!
ありがとうございました