SlideShare a Scribd company logo
12-Factor App
A Methodology for Building
SaaS Apps
MM Meetup, September 2015, Ankara
/Abdullah Cetin CAVDAR @accavdar
Me :)
Software Engineer
Continuous Reader / Learner
Runner / Rider
Snooker Lover
Headbanger m/
@udemy
12factor.net
What's 12-Factor
App?
It's a methodology for building
SaaS apps
Why do we care?
Tries to define the systematic
problems in app development
Tries to offer a set of broad
conceptual solutions to those
problems
What are the
properties of an
app?
Uses declarative format for
setup automation
to minimize time and cost for new developers joining the project
Has a clean contract with the
underlying operating system
offering maximum portability between execution environments
Is suitable for deployment on
modern cloud platforms
no need for servers and systems administration
Minimizes divergence between
development and production
enabling continuous deployment for maximum agility
Can scale up
without significant changes to tooling, architecture, or
development practices
The 12-Factors
1. Codebase
One codebase tracked in revision control,
many deploys
codebase == code repo == repo
tracked in a version control
system:  ,  ,   etc.git mercurial svn
one repo, many deploys
app != many repos
many repos = distributed system
2. Dependencies
Explicitly declare and isolate dependencies
PS: Think about new developers :)
Never rely on implicit existence of packages
Dependency Declaration
Declare all dependencies, completely and
exactly, via a dependency declaration
manifest
Dependency Isolation
Ensure that no implicit dependencies "leak
in" from the surrounding system
pip
virtualenv
source ~/udemy-py3-env/bin/activate &&
pip install -r requirements/dev.txt
Do not rely on the implicit
existence of any system tools
Bundle them with your app
3. Config
Store config in the environment
What's config?
Everything that is likely to vary
between deploys
Resource Handles (db, memcache, backing services, ...)
Credentials to external services (twitter, AWS, ...)
Per-deploy values (canonical hostname, ...)
PS: It does not include internal app config (config/routes.rb, bean
config, ...)
Can you make
your repo open
source?
Store config in Environment
Variables
Keep your config outside the app
Env vars are easy to change between deploys
No secret in version control
12-Factor App
12-Factor App
You may use Environments
but 12-Factor App recommends Env Vars
dev
test
staging
prod
...
It's also called Profiles
4. Backing Services
Treat backing services as attached resources
A backing service is any service
the app consumes over the
network
Data Store (MySQL, MongoDB, AWS S3...)
Messaging/Queueing Systems (RabbitMQ, Kafka, ...)
Caching Systems (Redis, Memcached, ...)
SMTP Services (Postfix, ...)
No distinction between local
and third party services
They are Attached Resources
accessed via a URL or other
locator/credentials stored in the config
12-Factor App
They are loosely coupled with the deployed app
They are easily swap out without any changes to the app’s code
Microservices?
5. Build, Release,
Run
Strictly separate build and run stages
A codebase is transformed into
a deploy through three stages
Build
Release
Run
Build
Converts a code repo into an
executable bundle
Build = Dependencies + Binaries + Assets
Release
Get the build and combine it
with the current config
Release = Build + Config
Run
Run the app in the execution
environment
Run = Run process against release
12-Factor App
Strict separation between the
build, release, and run stages
For example, it is impossible to make
changes to the code at runtime
Use tools to easily rollback to previous release
Version your releases with unique release ids (ex: v101)
Any change must create a new release
6. Processes
Execute the app as one or more stateless
processes
Processes are stateless and
share-nothing
Any data that needs to persist must be
stored in a stateful backing service
Never assume that anything cached in memory or on disk will be
available on a future request or job
Never use or rely on sticky sessions, use a data store that offers time-
expiration, such as Memcached or Redis
7. Port Binding
Export services via port binding
App is completely self-contained
The web app exports HTTP as a service by binding to a port
Use dependency declaration to
add a web server library
Tornado for Python
Thin for Ruby
Jetty or Tomcat for Java
Use it not only for HTTP
Any kind of service runs via a process binding to a port, i.e Redis
Port-binding approach means that one app can become the backing
service for another app
8. Concurrency
Scale out via the process model
Processes are a first class citizen
Developers can architect their app to handle diverse workloads by
assigning each type of work to a process type
HTTP requests may be handled by a web process
Long-running background tasks handled by a worker process
...
12-Factor App
Each process can handle its own multiplexing
Threads in runtime VM (Java, ...)
Async/Event model (Twisted, node.js, ...)
Use system process managers (i.e Upstart) to
Manage process
Respond to crash process
Handle user initiated restarts and shutdowns
Scale Out?
with share-nothing, horizontally partitionable nature of app processes
Simple and Reliable Concurrency
9. Disposability
Maximize robustness with fast startup and
graceful shutdown
Processes are disposable
meaning they can be started or stopped at
a moment’s notice
fast elastic scaling
rapid deployment of code and config changes
robustness of production deploys
Minimize startup time
more agility for the release process and scaling up
aids robustness
Shut down gracefully when
they receive a SIGTERM
Cease to listen on the service port, allow any current requests to
finish, and then exit (Web Process)
Return the current job to the work queue (Worker Process)
Try to make all jobs reentrant or
Make the operation idempotent
Be robust against sudden death
Use a robust queueing backend
RabbitMQ
Beanstalkd
Redis
10. Dev/Prod
Parity
Keep development, staging, and
production as similar as possible
Development vs Production
Gaps
Time Gap
A developer may work on code that takes
days, weeks, or even months to go into
production
Personnel Gap
Developers write code, ops engineers
deploy it
Tools Gap
Stack like Nginx, SQLite, and OS X in dev,
Apache, MySQL, and Linux in prod
Design for continuous
deployment
Keep the gap between development and
production small
Make the time gap small
A developer may write code and have it
deployed hours or even just minutes later
Make the personnel gap small
Developers who wrote code are closely
involved in deploying it and watching its
behavior in production
Make the tools gap small
Keep development and production as
similar as possible
Resist to use different backing services between development and
production
Chef, Puppet, ...
Docker, Vagrant, ...
12-Factor App
11. Logs
Treat logs as event streams
Never concern itself with
routing or storage of its output
stream
Each running process writes its event
stream, unbuffered, to stdout
Index and analyse (splunk,
hive/hadoop, ...) your event
streams to
Finding specific events in the past
Large-scale graphing of trends (such as requests per minute)
Active alerting according to user-defined heuristics
12. Admin Processes
Run admin/management tasks as one-off
processes
One-off administrative or
maintenance tasks for the app
Running DB migrations
Running a console (REPL shell)
Running one time script
Run them in an identical environment as the regular app
Ship with application code to avoid synchronization issues
Favor languages which provide a REPL shell out of the box
Also check:
Microservices
Reactive Manifesto
Containerization ( ,  ,
)
LXC Docker
CoreOS
Thank you :)
Questions?
THE END
by Abdullah Cetin CAVDAR / @accavdar

More Related Content

What's hot (20)

PPTX
Driving Enterprise Architecture Redesign: Cloud-Native Platforms, APIs, and D...
Chris Haddad
 
PDF
Cloud Native Computing: What does it mean, and is your app Cloud Native?
Michael O'Sullivan
 
PDF
Eseguire Applicazioni Cloud-Native con Pivotal Cloud Foundry su Google Cloud ...
VMware Tanzu
 
PDF
Costruire Applicazioni Cloud-Native con Spring Boot (Pivotal Cloud-Native Wor...
VMware Tanzu
 
PPTX
Bring Service Mesh To Cloud Native-apps
Thang Chung
 
PDF
Cloud Native Operations
Michael Mueller
 
PPTX
Modernizing Your Aging Architecture: What Enterprise Architects Need To Know ...
Legacy Typesafe (now Lightbend)
 
PDF
Dev Ops and PaaS - Accelerate Application Delivery with OpenShift
Frederik Bijlsma
 
PDF
IoT Scale Event-Stream Processing for Connected Fleet at Penske
VMware Tanzu
 
PPTX
Cloud Native Application Framework
VMware Tanzu
 
PPTX
Tectonic Summit 2016: Ticketmaster's Public Cloud & Kubernetes Strategy
CoreOS
 
PPTX
The Cloud Native Journey
VMware Tanzu
 
PDF
Using Google Cloud Services with Spring Boot and Pivotal Cloud Foundry (Pivot...
VMware Tanzu
 
PDF
Monitoring Serverless Applications with Datadog
DevOps.com
 
PPTX
App Mod 01: Moving existing apps to the cloud
Judy Breedlove
 
PDF
stackconf 2021 | Platform as a Product
NETWAYS
 
PPTX
Cloud Native Infrastructure Automation
VMware Tanzu
 
PPTX
The Cloud Native Journey with Simon Elisha
Chloe Jackson
 
PDF
Red Hat OpenShift - a foundation for successful digital transformation
Eric D. Schabell
 
PDF
cross cloud inter-operability with iPaaS and serverless for Telco cloud SDN/NFV
Krishna-Kumar
 
Driving Enterprise Architecture Redesign: Cloud-Native Platforms, APIs, and D...
Chris Haddad
 
Cloud Native Computing: What does it mean, and is your app Cloud Native?
Michael O'Sullivan
 
Eseguire Applicazioni Cloud-Native con Pivotal Cloud Foundry su Google Cloud ...
VMware Tanzu
 
Costruire Applicazioni Cloud-Native con Spring Boot (Pivotal Cloud-Native Wor...
VMware Tanzu
 
Bring Service Mesh To Cloud Native-apps
Thang Chung
 
Cloud Native Operations
Michael Mueller
 
Modernizing Your Aging Architecture: What Enterprise Architects Need To Know ...
Legacy Typesafe (now Lightbend)
 
Dev Ops and PaaS - Accelerate Application Delivery with OpenShift
Frederik Bijlsma
 
IoT Scale Event-Stream Processing for Connected Fleet at Penske
VMware Tanzu
 
Cloud Native Application Framework
VMware Tanzu
 
Tectonic Summit 2016: Ticketmaster's Public Cloud & Kubernetes Strategy
CoreOS
 
The Cloud Native Journey
VMware Tanzu
 
Using Google Cloud Services with Spring Boot and Pivotal Cloud Foundry (Pivot...
VMware Tanzu
 
Monitoring Serverless Applications with Datadog
DevOps.com
 
App Mod 01: Moving existing apps to the cloud
Judy Breedlove
 
stackconf 2021 | Platform as a Product
NETWAYS
 
Cloud Native Infrastructure Automation
VMware Tanzu
 
The Cloud Native Journey with Simon Elisha
Chloe Jackson
 
Red Hat OpenShift - a foundation for successful digital transformation
Eric D. Schabell
 
cross cloud inter-operability with iPaaS and serverless for Telco cloud SDN/NFV
Krishna-Kumar
 

Viewers also liked (13)

PDF
SaaS startups - Software Engineering Challenges
Malinda Kapuruge
 
PDF
Software Engineering in the Age of SaaS and Cloud Computing - SERA 2013 - MFF...
Jaroslav Gergic
 
PDF
Brief tutorial on Git
聖文 鄭
 
PDF
SaaS Business Model: A Unique Business Architecture
Lincoln Murphy
 
PDF
Heroku Javaで12-Factor App
Mitch Okamoto
 
PPT
SaaS: Introduction
Arief Gunawan
 
PPTX
12 factor app an introduction
Krishna-Kumar
 
PDF
Building SaaS products with Windows Azure
8KMiles Software Services
 
PDF
12-Factor
Luc Juggery
 
PDF
Advanced Git
segv
 
PPTX
Continuous Innovation + Digital Platforms
Cloud Foundry Foundation
 
PPT
The SaaS business model
David Skok
 
PDF
Advanced Git Tutorial
Sage Sharp
 
SaaS startups - Software Engineering Challenges
Malinda Kapuruge
 
Software Engineering in the Age of SaaS and Cloud Computing - SERA 2013 - MFF...
Jaroslav Gergic
 
Brief tutorial on Git
聖文 鄭
 
SaaS Business Model: A Unique Business Architecture
Lincoln Murphy
 
Heroku Javaで12-Factor App
Mitch Okamoto
 
SaaS: Introduction
Arief Gunawan
 
12 factor app an introduction
Krishna-Kumar
 
Building SaaS products with Windows Azure
8KMiles Software Services
 
12-Factor
Luc Juggery
 
Advanced Git
segv
 
Continuous Innovation + Digital Platforms
Cloud Foundry Foundation
 
The SaaS business model
David Skok
 
Advanced Git Tutorial
Sage Sharp
 
Ad

Similar to 12-Factor App (20)

PDF
Dairy management system project report..pdf
Kamal Acharya
 
PPTX
PureMVC
Guy Aharonovsky
 
PDF
Agile and continuous delivery – How IBM Watson Workspace is built
Vincent Burckhardt
 
PPTX
Twelve factor-app
José Javier Vélez Colón
 
PDF
Advanced Full Stack Development: Scaling, Deployment, and Maintenance
saniakhan8105
 
PDF
Let's banish "it works on my machine"
Stephanie Locke
 
PDF
Combining Cloud Native & PaaS: Building a Fully Managed Application Platform ...
DigitalOcean
 
PPTX
Harbour IT & VMware - vForum 2010 Wrap
HarbourIT
 
ODP
The Bespoke Software Product Factory (2007)
Peter Antman
 
PDF
PARKING ALLOTMENT SYSTEM PROJECT REPORT REPORT.
Kamal Acharya
 
PPTX
SoCal DevOps Meetup 1/26/2017 - Habitat by Chef
Trevor Hess
 
DOCX
What is Cloud Application Development.docx
Integrated IT Solutions
 
PDF
Spring Boot & Spring Cloud on PAS- Nate Schutta (1/2)
VMware Tanzu
 
DOC
Resume-Neha-AWS
Neha Gupta
 
PPTX
The twelve factor app
Ravi Okade
 
PDF
MuleSoft Surat Virtual Meetup#16 - Anypoint Deployment Option, API and Operat...
Jitendra Bafna
 
PPTX
Stephane Lapointe & Alexandre Brisebois: Développer des microservices avec Se...
MSDEVMTL
 
PPTX
Nyc mule soft_meetup_13_march_2021
NeerajKumar1965
 
PPT
Presentation 1 open source tools in continuous integration environment v1.0
Jasmine Conseil
 
PDF
Full Stack Web Development: Vision, Challenges and Future Scope
IRJET Journal
 
Dairy management system project report..pdf
Kamal Acharya
 
Agile and continuous delivery – How IBM Watson Workspace is built
Vincent Burckhardt
 
Twelve factor-app
José Javier Vélez Colón
 
Advanced Full Stack Development: Scaling, Deployment, and Maintenance
saniakhan8105
 
Let's banish "it works on my machine"
Stephanie Locke
 
Combining Cloud Native & PaaS: Building a Fully Managed Application Platform ...
DigitalOcean
 
Harbour IT & VMware - vForum 2010 Wrap
HarbourIT
 
The Bespoke Software Product Factory (2007)
Peter Antman
 
PARKING ALLOTMENT SYSTEM PROJECT REPORT REPORT.
Kamal Acharya
 
SoCal DevOps Meetup 1/26/2017 - Habitat by Chef
Trevor Hess
 
What is Cloud Application Development.docx
Integrated IT Solutions
 
Spring Boot & Spring Cloud on PAS- Nate Schutta (1/2)
VMware Tanzu
 
Resume-Neha-AWS
Neha Gupta
 
The twelve factor app
Ravi Okade
 
MuleSoft Surat Virtual Meetup#16 - Anypoint Deployment Option, API and Operat...
Jitendra Bafna
 
Stephane Lapointe & Alexandre Brisebois: Développer des microservices avec Se...
MSDEVMTL
 
Nyc mule soft_meetup_13_march_2021
NeerajKumar1965
 
Presentation 1 open source tools in continuous integration environment v1.0
Jasmine Conseil
 
Full Stack Web Development: Vision, Challenges and Future Scope
IRJET Journal
 
Ad

Recently uploaded (20)

PPTX
Water resources Engineering GIS KRT.pptx
Krunal Thanki
 
PPTX
MSME 4.0 Template idea hackathon pdf to understand
alaudeenaarish
 
PDF
STUDY OF NOVEL CHANNEL MATERIALS USING III-V COMPOUNDS WITH VARIOUS GATE DIEL...
ijoejnl
 
PPTX
Chapter_Seven_Construction_Reliability_Elective_III_Msc CM
SubashKumarBhattarai
 
PPTX
Module2 Data Base Design- ER and NF.pptx
gomathisankariv2
 
PDF
Introduction to Ship Engine Room Systems.pdf
Mahmoud Moghtaderi
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PDF
Air -Powered Car PPT by ER. SHRESTH SUDHIR KOKNE.pdf
SHRESTHKOKNE
 
PDF
Machine Learning All topics Covers In This Single Slides
AmritTiwari19
 
PDF
勉強会資料_An Image is Worth More Than 16x16 Patches
NABLAS株式会社
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PPTX
ETP Presentation(1000m3 Small ETP For Power Plant and industry
MD Azharul Islam
 
PDF
2010_Book_EnvironmentalBioengineering (1).pdf
EmilianoRodriguezTll
 
PPTX
Inventory management chapter in automation and robotics.
atisht0104
 
PPTX
Introduction to Fluid and Thermal Engineering
Avesahemad Husainy
 
PDF
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
PDF
Natural_Language_processing_Unit_I_notes.pdf
sanguleumeshit
 
PDF
Construction of a Thermal Vacuum Chamber for Environment Test of Triple CubeS...
2208441
 
PPTX
filteration _ pre.pptx 11111110001.pptx
awasthivaibhav825
 
PPTX
FUNDAMENTALS OF ELECTRIC VEHICLES UNIT-1
MikkiliSuresh
 
Water resources Engineering GIS KRT.pptx
Krunal Thanki
 
MSME 4.0 Template idea hackathon pdf to understand
alaudeenaarish
 
STUDY OF NOVEL CHANNEL MATERIALS USING III-V COMPOUNDS WITH VARIOUS GATE DIEL...
ijoejnl
 
Chapter_Seven_Construction_Reliability_Elective_III_Msc CM
SubashKumarBhattarai
 
Module2 Data Base Design- ER and NF.pptx
gomathisankariv2
 
Introduction to Ship Engine Room Systems.pdf
Mahmoud Moghtaderi
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
Air -Powered Car PPT by ER. SHRESTH SUDHIR KOKNE.pdf
SHRESTHKOKNE
 
Machine Learning All topics Covers In This Single Slides
AmritTiwari19
 
勉強会資料_An Image is Worth More Than 16x16 Patches
NABLAS株式会社
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
ETP Presentation(1000m3 Small ETP For Power Plant and industry
MD Azharul Islam
 
2010_Book_EnvironmentalBioengineering (1).pdf
EmilianoRodriguezTll
 
Inventory management chapter in automation and robotics.
atisht0104
 
Introduction to Fluid and Thermal Engineering
Avesahemad Husainy
 
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
Natural_Language_processing_Unit_I_notes.pdf
sanguleumeshit
 
Construction of a Thermal Vacuum Chamber for Environment Test of Triple CubeS...
2208441
 
filteration _ pre.pptx 11111110001.pptx
awasthivaibhav825
 
FUNDAMENTALS OF ELECTRIC VEHICLES UNIT-1
MikkiliSuresh
 

12-Factor App