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 Twelve-Factor App
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Kristian Glass
September 20, 2014
Programming
1.3k
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
The Twelve-Factor App
http://12factor.net/
- what, why, how
From PyCon UK 2014
Kristian Glass
September 20, 2014
More Decks by Kristian Glass
See All by Kristian Glass
How To Screw Up Hiring - Kristian Glass - PyCon UK 2018
doismellburning
0
550
Infrastructure as Code with AWS CloudFormation and Sceptre
doismellburning
0
3.7k
Other Decks in Programming
See All in Programming
Terraform標準の組織で AWS CDKをどう使うか
mu7889yoon
1
410
『コードを書く以外の』エンジニアリング〜課金基盤移行プロジェクト推進のためのTips4選
yuriko1211
0
550
エンジニアにデザインハーネスを 〜デザインプロセスを規定するためのハーネス〜 / Design harness from an engineer's perspective
rkaga
2
1.8k
信頼性について考えてみる(SRE NEXT 2026 miniLT)
hayama17
0
220
ソフトウェア設計に溶けるインフラ ― AWS CDK のインフラ認識論
konokenj
3
680
Apache Hive: そしてCloud Native Lakehouseへ
okumin
1
180
What's New in Android 2026
veronikapj
0
230
生成AI導入の「期待外れ」を乗り越える ー 開発フロー改革が目指す、真の組織変革
starfish719
0
2.6k
全PRの83%がAIレビューだけでマージできるようになった開発組織はその後どうなったか
athug
0
550
AI時代に設計が 最大の生産性レバーになる 意図駆動開発とデータを消さない設計|Don't Delete Your Data or Your Intent — Design as the Deepest Lever in the AI Era
tomohisa
0
110
数百円から始めるRuby電子工作
tarosay
0
110
FDEが実現するAI駆動経営の現在地
gonta
2
230
Featured
See All Featured
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.9k
Building Adaptive Systems
keathley
44
3.1k
New Earth Scene 8
popppiees
3
2.4k
Deep Space Network (abreviated)
tonyrice
0
240
Amusing Abliteration
ianozsvald
1
240
Claude Code のすすめ
schroneko
67
230k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
430
Leo the Paperboy
mayatellez
8
1.9k
Side Projects
sachag
455
43k
Technical Leadership for Architectural Decision Making
baasie
3
450
The untapped power of vector embeddings
frankvandijk
2
1.8k
Producing Creativity
orderedlist
PRO
348
40k
Transcript
The Twelve-Factor App Kristian Glass @doismellburning http://www.doismellburning.co.uk/talks/django12factor 1
•I do development •I do operations •I write code and
care how it runs 2
What is Twelve Factor? “A methodology for building web apps”
3
Core Concept Clean interface between app and underlying system 4
#1 One code repository, many deploys 5
#2 Explicitly declare and isolate dependencies 6
So, virtualenv and requirements.txt ? 7
$ pip install -r requirements.txt! # …! Downloading/unpacking gevent! Running
setup.py egg_info for package gevent! # …! gevent/libevent.h:9:19: error: event.h: No such file or directory! # …! error: command 'gcc-4.2' failed with exit status 1 8
So how? •Containers/VMs •OS packages (ish) 9
#3 Read config from the environment 10
What is Config? Everything likely to vary between deploys 11
Config Examples •Service URLs (Database, mail, etc.) •Service credentials •Debug
flag 12
Why do this? •Separation of responsibility •Language and framework independent
•Avoid leakage of secrets 13
But config files? •Apps read from environment •Environment may come
from files 14
How do I populate the environment? • foreman • honcho
• envdir • supervisor • bash scripts • and more… 15
Using Django? https://github.com/doismellburning/ django12factor 16
#4 Treat backing services as attached resources 17
Attached Resources •No distinction between local/external resources •Loose coupling 18
#5 Distinct build/ release/run stages 19
Build / Release? build :: Code -> Executable! ! release
:: Config -> Executable -> Release Artefact 20
Example: Building a Django Project $ git clone! $ virtualenv!
$ pip install -r requirements.txt! $ manage.py collectstatic ! $ fpm 21
Releases •New config? New release •New code? New build, new
release 22
Run stage As simple as possible 23
Why? •Do hard work in advance •Optimise the common case
24
#6 Run as stateless process(es) 25
Stateless Processes •Persist data to external services •Assume nothing about
RAM/ disk •No sticky sessions 26
#7 Export services via port binding 27
What does this mean? •Your app should offer its services
by some protocol on some port •Self-contained services: run and go 28
#8 Scale out with processes 29
Process model •More load? More processes •Background jobs? Worker processes
•Don’t daemonise, that’s manager’s job 30
#9 Start quickly, stop nicely 31
Start quickly, stop nicely •Disposable apps •Auto-scale easily •Deploy quickly
and easily 32
#10 Keep environments as similar as possible 33
Three prod/dev gaps •Time gap •People gap •Tools gap 34
Time gap •“Production is weeks behind dev” •Solution: Deploy more
35
People gap •“Developers write code, Ops run it” •Solution: DevOps
36
Tool gap •“It works on my machine” •Solution: Use the
same tools everywhere 37
#11 Treat logs as event streams 38
Logs as event streams •No logfile / routing / storage
handling •Spit logs out to stdout •One event, one line 39
#12 Admin tasks as part of your app 40
What does that mean? •Django management commands are a great
example •$ python manage.py syncdb! •No private folders of “useful snippets” •Keep them with the app 41
Recap 1. One codebase 2. Dependencies 3. Config in environment
4. Backing Services 5. Build, release, run 6. Stateless processes 7. Port binding 8. Scale with processes 9. Disposability 10. Dev/prod parity 11. Logs as event stream 12. Admin processes 42
Recap •It does not matter what language •It does not
matter what framework 43
Questions? http://www.doismellburning.co.uk/talks/django12factor 44