14
Twelve Factor App Tomasz Skręt

Twelve Factor App @ PHPCon 2015

Embed Size (px)

Citation preview

Page 1: Twelve Factor App @ PHPCon 2015

Twelve Factor AppTomasz Skręt

Page 2: Twelve Factor App @ PHPCon 2015

I. Codebase

• One repository - GIT :)• One application per

repository• Extract shared code into

libraries• Running instance - deploy

Tomasz Skręt - Twelve Factor App 2

Page 3: Twelve Factor App @ PHPCon 2015

II. Dependencies

● Use packaging system● Isolate dependencies● Do not rely on system

tools● Installing dependencies

should be simple, one command process

Tomasz Skręt - Twelve Factor App 3

Page 4: Twelve Factor App @ PHPCon 2015

III. Config

• Store config in environment• Each deploy has own config• Do not checkout into

repository• Do not group config values

as a environments

Tomasz Skręt - Twelve Factor App 4

Page 5: Twelve Factor App @ PHPCon 2015

IV. Backing Services

Attached resources

• Databases• File storage• Cache• Queue• APIs

Tomasz Skręt - Twelve Factor App 5

Page 6: Twelve Factor App @ PHPCon 2015

V. Build, release, run

• build - checkout codebase, install dependencies, run tests, produce artifact• release - combine build

artifact with environment config• run - run application

processes

Every release have version

Tomasz Skręt - Twelve Factor App 6

3 stages:

Page 7: Twelve Factor App @ PHPCon 2015

VI. Processes

Tomasz Skręt - Twelve Factor App 7

stateless

share nothing

use backing services

Page 8: Twelve Factor App @ PHPCon 2015

VII. Port binding

• expose application by binding to port• one twelve factor app can

become backing service for another• in PHP to expose HTTP service,

we can use nginx or haproxy

Tomasz Skręt - Twelve Factor App 8

Page 9: Twelve Factor App @ PHPCon 2015

VIII. Concurrency

Tomasz Skręt - Twelve Factor App 9

scale by creating new processes

don’t write PID files - use ex. upstart, systemd, foreman

Page 10: Twelve Factor App @ PHPCon 2015

IX. Disposability

• applications are disposable - easy to scale, change configuration, deploy new version• fast start• gracefully shutdown

Tomasz Skręt - Twelve Factor App 10

Page 11: Twelve Factor App @ PHPCon 2015

X. Dev/prod parity

• environments should be similar to production as much as possible• keep time gap small• environment should be

setup fast and easy• backing services can be

changed to another, ex. to simplify development process

Tomasz Skręt - Twelve Factor App 11

Page 12: Twelve Factor App @ PHPCon 2015

XI. Logs

• Treat logs as event streams• twelve-factor app never

concerns itself with routing or storage of its output stream• logs are collected from

application and all backing services

Tomasz Skręt - Twelve Factor App 12

Page 13: Twelve Factor App @ PHPCon 2015

XII. Admin processes

• one-off process• should run in identical environment - run the same

codebase and config as application - use release• can be script, committed to repo• REPL console

Tomasz Skręt - Twelve Factor App 13

Page 14: Twelve Factor App @ PHPCon 2015

Thank you for watching!

Questions?