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
The 12Factor App
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Damien Mathieu
October 30, 2014
Programming
1k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
The 12Factor App
Damien Mathieu
October 30, 2014
Transcript
57 slides
@dmathieu Software Engineer @heroku The 12Factor App 1
Twelve Factor • Can apply to any language and platform!
• Speeds up deployment! • Makes scaling easier! • Keeps apps clean 2
Let’s take a look 3
One codebase to rule them all 4
Codebase Production Staging Feature A Feature B 5
6 Multiple codebases is a distributed system
7 Create libraries
Explicitly declare and isolate dependencies 8
9 source 'https://rubygems.org' ! ruby '2.1.3' ! gem 'rails' gem
'pg' gem 'puma'
10
11 curl imagemagick
12 Config never goes in source control
Config Resource strings to databases Credentials to S3, Facebook, Twitter,
… Security Tokens 13
$ cat .env! AWS_TOKEN=QWERTYUIOP! AWS_SECRET=12345 ! GITHUB_APP_ID=1! GITHUB_SECRET=67890 14
$ foreman run rails console! >> puts ENV[‘AWS_TOKEN’]! > “QWERTYUIOP”
15
You can use a yml config file* *Just don’t store
it in source control
Treat backing services as attached resources 17
18 DATABASE_URL= postgres://example.com:5032
Production deploy PostgreSQL Email Service Amazon S3
20 One codebase per app Explicitly declare and isolate dependencies
Don’t put config in source control Treat backing services as attached resources
Build Release Run 21
Codebase Build Run Config 22
Codebase Build Run Config 23
Execute the app as one or more stateless processes 24
web.1 web.2 Database 25
26 No sticky sessions
27 Ephemeral filesystem
28 Export services via port binding
29 Self-contained app
30 An app can be the backing service for an
other
Scale out via the process model 31
web.1 web.2 web.3 worker.1 worker.2 clock.1 32
33 You can still do your own internal multiplexing
34 Build, release, run One or more stateless processes Scale
out via the process model Export services via port binding
Maximize robustness with fast startup and graceful shutdown 35
36 Handle a request
37 60s to boot is a lot
38 Use the SIGTERM signal
39 Send jobs back to the queue
40 Build, release, run One or more stateless processes Scale
out via the process model Fast startup
Keep development, staging, and production as similar as possible 41
42 Use the same kind of machine
43 With the same OS version
44 And the same database server
Logging 45
46 Production errors will happen
47 Tail logs to find the cause
48 Then use a logging service to dig in deeper
action=create_user
[email protected]
action=log_user
[email protected]
49
count#api-call-200=1 50
Don’t write logs to a file 51
Run admin/ management tasks as one-off processes 52
53 Not in your app’s main processes
54 Run console instances the same way
55 Keep all your environments as similar as possible Run
management tasks as one-off processes Logging
Do you like? • Minimizing new developer overhead?! • Running
in multiple environments?! • Easily scaling without tooling, architecture or development headaches?! • Having the latest update available to users at a moments notice? Read more at 12factor.net 56
Questions?
[email protected]
12factor.net 57 @dmathieu
More Decks by Damien Mathieu
See All by Damien Mathieu
Open-source sans Burn Out ? Le modèle CNCF
dmathieu
0
85
Let's deploy on fridays
dmathieu
0
270
Building Resilient Services
dmathieu
0
200
Easily monitor your product data
dmathieu
0
71
Play with ruby threads
dmathieu
2
140
Other Decks in Programming
See All in Programming
あなたの await、OS まで届いてる? strace で覗く JavaScript の非同期
hasutosasaki
1
2.4k
Kotlin JVM用に作られたライブラリのKMPを前提とした再設計
jsoizo
0
220
Claude Code ハーネスDeep Dive – 君はどこまで制御する? -
takateeen_knj
6
6.2k
AI駆動開発4年目の現在地(『あなたはFDEになるべきか?』イベント資料)
kumaiu
0
690
AIコーディング時代のKotest ユニットテストから APIレベルの仕様固定化テストへ
ooga04
0
320
Rails初心者がパスキーを実装してみて大変だったこと
ktombow
0
230
Agentic AI with the Power of Jakarta EE
ivargrimstad
0
140
将来の標準フォーマッター?ktfmtを深堀る
t45k
0
240
AppFunctionsの内部実装を紐解く
hiroaki404
0
110
Growing PicoRuby's Ecosystem on ESP32
yuuu
2
150
Distance field of Julia set
kinakomoti321
0
330
読みやすい!と評判(?)の発表の準備にかける私のこだわり
shoheimitani
0
130
Featured
See All Featured
Speed Design
sergeychernyshev
33
2.2k
Faster Mobile Websites
deanohume
310
32k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
1
310
The Mindset for Success: Future Career Progression
greggifford
PRO
0
570
Automating Front-end Workflow
addyosmani
1370
210k
Designing Powerful Visuals for Engaging Learning
tmiket
1
660
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.5k
Design in an AI World
tapps
1
390
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
68
61k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
330
Skip the Path - Find Your Career Trail
mkilby
1
300