12 factor app

DmytroPanin 253 views 53 slides Feb 09, 2018
Slide 1
Slide 1 of 53
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49
Slide 50
50
Slide 51
51
Slide 52
52
Slide 53
53

About This Presentation

Nowadays many organizations are heading towards numerous cloud solutions, while, even more, organizations are already there. In order not to negate advantages that cloud can provide us with, I would like to go through a methodology or rather a set of best practices designed to improve maintainabilit...


Slide Content

WHAT IS A 12 FACTOR APP? Arch9: Amsterdam, The Netherlands

HELLO! I am Dmytro Panin Found of Java, Cloud, IoT ⦿

CLOUD IS EVERYWHERE ⦿

“ Cloud - access to a pool of computing resources (servers, storage, networks, services etc) that can be rapidly provisioned and made available with minimal overhead ” ⦿

⦿

The 12 factors are language and technology agnostic ⦿

BENEFITS OF THE 12 FACTORS Minimize time and cost for a new developer joining the project M aximum portability between execution environments Scale up without significant changes ⦿

12 factors Set of principles that prepare your app for the best experience in cloud ⦿

CODEBASE One codebase tracked in revision control, many deploys 1

One codebase per application 1

Submodules if exist should be separated by VCS 1

DEPENDENCIES Explicitly declare and isolate dependencies 2

System-wide 12 factor app never relies on system-wide dependencies DEPENDENCIES Isolated dependencies are declared explicitly 2

CONFIG Store config in the environment 3

12 FACTOR CONFIG Backing services Resource handles to the services that are required for the app Example: Database Passwords Credentials to external services Example: Twitter Per-deploy values Values that differ based on an environment Example: Hostname 3

12 FACTOR CONFIG Backing services Resource handles to the services that are required for the app Example: Database Passwords Credentials to external services Example: Twitter Per-deploy values Values that differ based on an environment Example: Hostname 3

12 FACTOR CONFIG Backing services Resource handles to the services that are required for the app Example: Database Passwords Credentials to external services Example: Twitter Per-deploy values Values that differ based on an environment Example: Hostname 3

NOT 12 FACTOR CONFIG Configuration of a framework is not 12 factor app conf Routes do not vary between deploys, thus, better stored in code. 3

CONFIGURATION FILES 3 Number of configuration files that you have right now for all of your environments Number of environments may grow over time as well as number of configuration files in your app’s repository

CONFIG The 12 factor app stores config in environment variables 3 OS-agnostic standard Little chance of committing into the repo Having config separated helps to scale out easier

THE LITMUS TEST 3

BACKING SERVICES Treat backing services as attached resources 4

RESOURCES 4

LOCAL OR 3rd PARTY 4 The code for a twelve-factor app makes no distinction between local and third-party services

BUILD, RELEASE, RUN Strictly separate build and run stages 5

STAGES 5 BUILD RELEASE RUN Strict separation between the stages

VERSIONING Every release should always have a unique release ID 5 Timestamp Incrementing number A release cannot be mutated once it is created

PROCESSES Execute the app as one or more stateless processes 6

STATELESS 6 Twelve-factor processes are stateless and share-nothing Any data that needs to persist must be stored in a stateful backing service

STICKY SESSIONS 6 Sticky sessions are a violation of the twelve factors

PORT BINDING Export services via port binding 7

SELF CONTAINED 7 The 12 factor app is self-contained Do not require an application container Embeds a webserver library The web app exports HTTP as a service by binding to a port

SELF CONTAINED 7 The 12 factor app is self-contained Do not require an application container Embeds a webserver library The web app exports HTTP as a service by binding to a port

SELF CONTAINED 7 The 12 factor app is self-contained Do not require an application container Embeds a webserver library The web app exports HTTP as a service by binding to a port

CONCURRENCY Scale out via the process model 8

VERTICAL 8 Scale up is not enough

HORIZONTAL 8 Scale out

PROCESS MODEL 8 Microservices

DISPOSABILITY F ast startup and graceful shutdown 9

DISPOSABILITY 9 Maximize robustness Minimize startup time Shut down gracefully

RESILIENCE 9 Be robust against sudden death

DISPOSABILITY 9 Don’t be too attached to your servers Servers are a commodity

DEV/PROD PARITY Keep dev, staging and prod as similar as possible 10

TOOLS 10 SQLite ≠ MySQL

TIME 10 Code is in production a few hours after a commit

PERSONNEL 10 Developers should deploy their code

LOGS Treat logs as event streams 11

LOGS 11

LOGS 11 12 factor app don’t route or storage its output stream

ADMIN PROCESSES Run admin/management tasks as one-off processes 12

Codebase Dependencies Config Backing services Build, release, run Processes Port binding Concurrency Disposability Dev/prod parity Logs Admin processes LET’S RECAP ⦿

DETAILS http://12factor.net ⦿

QUESTIONS?