twelve factor app @ phpcon 2015

Post on 13-Apr-2017

328 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Twelve Factor AppTomasz Skręt

I. Codebase

• One repository - GIT :)• One application per

repository• Extract shared code into

libraries• Running instance - deploy

Tomasz Skręt - Twelve Factor App 2

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

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

IV. Backing Services

Attached resources

• Databases• File storage• Cache• Queue• APIs

Tomasz Skręt - Twelve Factor App 5

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:

VI. Processes

Tomasz Skręt - Twelve Factor App 7

stateless

share nothing

use backing services

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

VIII. Concurrency

Tomasz Skręt - Twelve Factor App 9

scale by creating new processes

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

IX. Disposability

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

Tomasz Skręt - Twelve Factor App 10

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

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

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

Thank you for watching!

Questions?

top related