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
70
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
120
FutureWorkz DevOps Workshop Day II - Deploying Rails
hqc
0
50
FutureWorkz DevOps Workshop Day III - Gitlab Runner for CD
hqc
0
96
Futureworkz DevOps Workshop Day 1 - DevOps ToolChain
hqc
0
70
FutureWorkz DevOps Workshop Intro
hqc
1
61
Rack for beginners
hqc
0
70
Chat Implementation with RESTful (Ruby) and Web Socket
hqc
0
62
Monkey patching in Ruby
hqc
0
300
Other Decks in Technology
See All in Technology
MCP とマネージド PaaS で実現する大規模 AI アプリケーションの高速開発
nahokoxxx
1
660
振り返りTransit Gateway ~VPCをいい感じでつなげるために~
masakiokuda
4
220
SRE with AI:実践から学ぶ、運用課題解決と未来への展望
yoshiiryo1
1
450
エンジニアリングマネージャー“お悩み相談”パネルセッション
ar_tama
1
300
AWS 怖い話 WAF編 @fillz_noh #AWSStartup #AWSStartup_Kansai
fillznoh
0
140
Amplify Gen2から知るAWS CDK Toolkit Libraryの使い方/How to use the AWS CDK Toolkit Library as known from Amplify Gen2
fossamagna
1
370
Frontier Airlines Customer®️ USA Contact Numbers: Complete 2025 Support Guide
frontierairlineswithflyagent
0
100
「Chatwork」のEKS環境を支えるhelmfileを使用したマニフェスト管理術
hanayo04
1
410
Semantic Machine Intelligence for Vision, Language, and Actions
keio_smilab
PRO
2
310
サイバーエージェントグループのSRE10年の歩みとAI時代の生存戦略
shotatsuge
4
1.1k
RapidPen: AIエージェントによる高度なペネトレーションテスト自動化の研究開発
laysakura
1
250
PHPからはじめるコンピュータアーキテクチャ / From Scripts to Silicon: A Journey Through the Layers of Computing
tomzoh
2
320
Featured
See All Featured
Faster Mobile Websites
deanohume
308
31k
Fireside Chat
paigeccino
37
3.5k
Statistics for Hackers
jakevdp
799
220k
Done Done
chrislema
184
16k
KATA
mclloyd
30
14k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Into the Great Unknown - MozCon
thekraken
40
1.9k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
It's Worth the Effort
3n
185
28k
Reflections from 52 weeks, 52 projects
jeffersonlam
351
21k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
130
19k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.4k
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!