Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Optimize Rails Asset Pipeline Deployment
Search
Cam Huynh
October 11, 2015
Technology
0
67
Optimize Rails Asset Pipeline Deployment
Cam Huynh
October 11, 2015
Tweet
Share
More Decks by Cam Huynh
See All by Cam Huynh
Reddit Ruby Conf 2016 Recap
hqc
0
110
FutureWorkz DevOps Workshop Day II - Deploying Rails
hqc
0
46
FutureWorkz DevOps Workshop Day III - Gitlab Runner for CD
hqc
0
91
Futureworkz DevOps Workshop Day 1 - DevOps ToolChain
hqc
0
67
FutureWorkz DevOps Workshop Intro
hqc
1
58
Rack for beginners
hqc
0
69
Chat Implementation with RESTful (Ruby) and Web Socket
hqc
0
57
Monkey patching in Ruby
hqc
0
300
Other Decks in Technology
See All in Technology
組織に自動テストを書く文化を根付かせる戦略(2024冬版) / Building Automated Test Culture 2024 Winter Edition
twada
PRO
25
6.9k
20241125 - AI 繪圖實戰魔法工作坊 @ 實踐大學
dpys
1
430
Fearsome File Formats
ange
0
540
3年でバックエンドエンジニアが5倍に増えても破綻しなかったアーキテクチャ そして、これから / Software architecture that scales even with a 5x increase in backend engineers in 3 years
euglena1215
11
4.2k
mixi2 の技術スタックを探ってみる (アプリ編)
ichiki1023
0
110
[JAWS-UG新潟#20] re:Invent2024 -CloudOperationsアップデートについて-
shintaro_fukatsu
0
140
信頼されるためにやったこと、 やらなかったこと。/What we did to be trusted, What we did not do.
bitkey
PRO
0
940
OCI技術資料 : ファイル・ストレージ 概要
ocise
3
12k
Storage Browser for Amazon S3
miu_crescent
1
340
TSKaigi 2024 の登壇から広がったコミュニティ活動について
tsukuha
0
180
The key to VCP-VCF
mirie_sd
0
140
新しいスケーリング則と学習理論
taiji_suzuki
9
3.4k
Featured
See All Featured
Navigating Team Friction
lara
183
15k
Code Reviewing Like a Champion
maltzj
521
39k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
111
50k
Site-Speed That Sticks
csswizardry
2
210
Unsuck your backbone
ammeep
669
57k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
1.2k
Facilitating Awesome Meetings
lara
50
6.2k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.2k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.9k
Learning to Love Humans: Emotional Interface Design
aarron
274
40k
Transcript
ASSET PIPELINE OPTIMIZATION by @huynhquancam
WHAT SHOULD YOU KNOW ABOUT THIS GUY? My name is
Huynh Quan Cam. Responsible for the development and engineering of Dadadee.
WHAT’S THE TALK ABOUT? Rails Assets pipeline. Deploy assets pipeline
on multiple servers. How to optimize the deployment?
ASSETS PIPELINE concatenate and minify or compress JavaScript and CSS
assets. support pre-processors such as CoffeeScript, Sass and ERB. based on Sprockets.
USING ASSET PIPELINE
– The Rails core team. “TIPS OF THE DAY” You
can get rid of sprockets by executing this command at the start. rails new my-awesome-app-without-sprockets --skip-sprockets
SITUATION we are deploying an Rails app to four servers:
2 web, 1 database and 1 worker. db and worker servers need static assets to work. zero-down time deployment and rollback required.
CAPISTRANO-RAILS capistrano-rails is a set of Capistrano tasks to automate
Rails deployment. migrations. assets pre-compilation.
ORCHESTRATION SCRIPT
WHAT’S WRONG WITH THIS APPROACH? waste of time. waste of
computing resources. waste of storage resources, especially when you’re using CDNs like CloudFront.
Can we only pre-compile once?
ASSET FINGERPRINTS generated based on file content. optimize client-side caching.
better cache invalidation.
ASSET FINGERPRINT application.css application-908e25f4bf641868d8683022a5b62f54.css application.css application-723d1be6cc741a3aabb1cec24276d681.css
ASSET MANIFEST a manifest-<md5-hash>.json cache every fingerprint of your Rails
static assets. accelerate Rails helper call.
ASSET MANIFEST
NOTES fingerprints only change if file contents change. fingerprints don’t
change across servers. all fingerprint requests are handled by manifest file.
Pre-compile once and sync the manifest file to others.
IMPLEMENTATION
IMPLEMENTATION
QUESTIONS?
THANK YOU!