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
The 12Factor App
Search
Damien Mathieu
October 30, 2014
Programming
1
950
The 12Factor App
Damien Mathieu
October 30, 2014
Tweet
Share
More Decks by Damien Mathieu
See All by Damien Mathieu
Let's deploy on fridays
dmathieu
0
170
Building Resilient Services
dmathieu
0
110
Easily monitor your product data
dmathieu
0
38
Play with ruby threads
dmathieu
2
100
Other Decks in Programming
See All in Programming
大規模マルチテナントを解決するYugabyteDBという選択肢
nnaka2992
1
250
わかりやすい正解を捨てて、コトに向き合う - スクラムフェス金沢2024 スポンサーセッション
yusukekokubo
0
170
20240706_CDKConf
takuyay0ne
0
1.2k
生成AIをkintoneに連携してみた
hideg
0
230
Harnessing Large Language Models for Training-free Video Anomaly Detection
tereka114
1
1.3k
Microservices rules (July 2024) : what good looks like
cer
PRO
0
1.6k
I/O Extended Android in Korea 2024 ~ Whats new in Android development tools
pluu
0
250
DMMプラットフォームにおけるTiDBの導入から運用まで
pospome
7
3k
Exploring the Gradually Lost Technical Skills in the Cloud Native Era
hwchiu
2
3.9k
유연한 Composable 설계
l2hyunwoo
0
380
Terraformテスト入門
msato
0
530
APIのない大学ログインWebサービスをWKWebViewとJavaScriptでアプリ化した話
akidon0000
1
330
Featured
See All Featured
The World Runs on Bad Software
bkeepers
PRO
63
11k
RailsConf 2023
tenderlove
16
720
The Mythical Team-Month
searls
217
43k
GraphQLとの向き合い方2022年版
quramy
36
13k
From Idea to $5000 a Month in 5 Months
shpigford
377
46k
Web development in the modern age
philhawksworth
203
10k
Optimizing for Happiness
mojombo
373
69k
10 Git Anti Patterns You Should be Aware of
lemiorhan
652
58k
Fantastic passwords and where to find them - at NoRuKo
philnash
42
2.7k
We Have a Design System, Now What?
morganepeng
46
7k
Into the Great Unknown - MozCon
thekraken
20
1.3k
4 Signs Your Business is Dying
shpigford
178
21k
Transcript
@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