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 Twelve-Factor App
Search
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
Transcript
44 slides
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
More Decks by Kristian Glass
See All by Kristian Glass
How To Screw Up Hiring - Kristian Glass - PyCon UK 2018
doismellburning
0
560
Infrastructure as Code with AWS CloudFormation and Sceptre
doismellburning
0
3.8k
Other Decks in Programming
See All in Programming
高速開発を止めずに 性能を上げる Flyleのシステム刷新と改善の歴史
azihsoyn
0
110
Beyond Chatbots: Agentic UI with Open Standards @W-JAX 2026, München
manfredsteyer
PRO
0
130
疎結合とは何か?ソフトウェア設計における結合バランスについて考える #phpcon_niigata
kajitack
2
420
Promiseの向こう側へコンテキストを届ける ― proposal-async-context
seriseri
0
160
仕様駆動開発入門 (何を作るかを先に決めて渡す) | 目指せ Kiro マスター 05
inariku
PRO
3
230
Agentic AI with the Power of Jakarta EE
ivargrimstad
0
200
How SRE Grew Out of Server-Side Work and Became the Team's Own / サーバサイドから始まったSREを チームに渡すまで
maaaato
1
260
[DroidKnights 2026] Workflow AX 적용기 — 자동 정책 정리부터 E2E까지
dayeon
0
120
コード生成時代のAPI定義を支えるRequest Spec移行
pvcresin
0
300
Spec-driven Development with AI
simas
PRO
0
2.3k
AIが生成したコードは読むべきか?抽象化設計とコードの品質保証 / abstraction-design-and-quality
minodriven
17
9.6k
Secure Your Coding Agent Like It’s Malware (v1.5) 🇬🇧 @Code.talks 2026
richargh
0
210
Featured
See All Featured
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
18k
Site-Speed That Sticks
csswizardry
13
1.6k
Large-scale JavaScript Application Architecture
addyosmani
516
110k
The browser strikes back
jonoalderson
0
2k
Embracing the Ebb and Flow
colly
88
5.2k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.3k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3.1k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
590
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
440
Optimizing for Happiness
mojombo
378
72k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
470
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k