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
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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.8k
Other Decks in Programming
See All in Programming
PyConJP2026_wat_Python × Signal Processing: How to Draw Pictures with Sound Using Spectrogram Art
wat
0
670
RSSとCodexを使ってX投稿自動化してみた
ochtum
0
110
XHTMLが残したもの
yosuke_furukawa
PRO
2
420
kubernetes コンポーネント開発入門 / 新卒N年目の勉強会&交流会!〜〇〇への誘い〜 #n_study
mazrean
0
170
iOS開発×AI駆動開発 〜最近使って便利だったスキルの話〜
nogu66
0
140
Go × SIMDで高速化するベクトル検索 ~ルーフラインモデルでSIMDが効く境界を探れ! ~
po3rin
1
140
tsc.rip を支える技術 / Kyoto.なんか #8
susisu
0
4.3k
AI時代に学ぶ 好きなルール 嫌いなルール Linter編
shorty5121
0
870
AIエージェント時代のコードレビューを設計する
nogu66
6
2.5k
in-process GraphQL のすすめ #ginzajs
izumin5210
4
1.5k
DroidKaigi 2026 「個人開発という実験場: Android エンジニアが手にする4つの自由」
slashnephy
0
220
ハーネス設計入門 〜プロンプト、コンテキストの次〜
kinopeee
55
36k
Featured
See All Featured
Building Flexible Design Systems
yeseniaperezcruz
330
41k
Six Lessons from altMBA
skipperchong
29
4.5k
30 Presentation Tips
portentint
PRO
1
390
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
3k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.5k
Producing Creativity
orderedlist
PRO
348
41k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
490
Joys of Absence: A Defence of Solitary Play
codingconduct
1
480
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.3k
Test your architecture with Archunit
thirion
2
2.4k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
69
65k
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