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
63
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
99
FutureWorkz DevOps Workshop Day II - Deploying Rails
hqc
0
42
FutureWorkz DevOps Workshop Day III - Gitlab Runner for CD
hqc
0
90
Futureworkz DevOps Workshop Day 1 - DevOps ToolChain
hqc
0
62
FutureWorkz DevOps Workshop Intro
hqc
1
55
Rack for beginners
hqc
0
67
Chat Implementation with RESTful (Ruby) and Web Socket
hqc
0
50
Monkey patching in Ruby
hqc
0
290
Other Decks in Technology
See All in Technology
さらばあのボタンとは言わせない SORACOM LTE-M Button powerd by AWSをまだ使えるようにした(前編?)
miura55
0
100
ゼロから始めるVue.jsコミュニティ貢献 / first-vuejs-community-contribution-link-and-motivation
lmi
1
150
Cypress or Playwright?
rainerhahnekamp
0
180
BPStudyの200回を中心にIT業界を振り返る。そしてこれから
haru860
3
430
認知症フレンドリーテックとスタックチャン
naokiuc
0
310
一生覚えておきたい「システム開発=コミュニケーション」〜初めての実務案件振り返りLT〜
maimyyym
3
400
Autonomous Database Cloud 技術詳細 / adb-s_technical_detail_jp
oracle4engineer
PRO
15
35k
Building Dashboards as a Hobby
egmc
0
410
LayerXにおけるLLMプロダクト開発の今までとこれから
layerx
PRO
4
790
しくじり先生、PharmaXのLLMアプリケーション開発の失敗を語る
pharma_x_tech
0
100
Python と Snowflake はズッ友だょ!~ Snowflake の Python 関連機能をふりかえる ~
__allllllllez__
2
150
「見せ球」「作って終わり」のLLM機能卒業のために
ryokaneoka0406
0
130
Featured
See All Featured
Intergalactic Javascript Robots from Outer Space
tanoku
266
26k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
22
1.6k
Clear Off the Table
cherdarchuk
85
310k
How GitHub Uses GitHub to Build GitHub
holman
468
290k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
41
4.4k
Pencils Down: Stop Designing & Start Developing
hursman
117
11k
Automating Front-end Workflow
addyosmani
1357
200k
Design by the Numbers
sachag
274
18k
5 minutes of I Can Smell Your CMS
philhawksworth
199
19k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
15
1.6k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
323
20k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
352
28k
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!