12 Factor App
- tags
- Deployment, Software Engineering
URL Created by Developers at Heroku in 2011 and got very popular.
The Twelve Factors #
Redhat article on the subject with illustrations
12 Factor App in context of Django
Some elements of the this Gartner’s report are covered by 12 Factor app.
I. Codebase #
One codebase tracked in revision control, many deploys

II. Dependencies #
Explicitly declare and isolate dependencies

Using Ansible, or Chef for Virtual Machine envs and in container based environment to manage dependencies.
III. Configuration #
Store config in the environment, externalize config data from the application. The config values should be read by the code at runtime from the environment, RAM, and config management tools like Ansible can be used to automate and manage configs, deploy them to runtimes when they change. This avoids re-deployment of application when config changes.

Django #
IV. Backing services #
Treat backing services as attached resources The 12 factor app should be able to swap the different services, e.g. database, from different provider, from DigitalOcean to OCI, without changing code.

V. Build, release, run #
Strictly separate build and run stages Use CI/CD to automate these processes.

For containers images should be built for every commit.
VI. Processes #
Execute the app as one or more stateless processes To leverage stateless nature of REST, services can be horizontally scaled without impact.
don’t store the state in memory store it the database.
VII. Port binding #
Export services via port binding not through direct access to the database.
- Application should be self contained
- Allow access to the persistent data owned by service by means of API only, no direct access
- This prevents implicit service contracts between microservices, make the dependencies explicit and through API interfaces only.

VIII. Concurrency #
Scale out via the process model, prefer vertical scaling.

IX. Disposability #
Maximize robustness with fast startup and graceful shutdown
- system should be impacted when new ones are added or existing ones are taken down
- impact should be minimal
X. Dev/prod parity #
Keep development, staging, and production as similar as possible

XI. Logs #
Treat logs as event streams
- provides window into the application behavior

XII. Admin processes #
Run admin/management tasks as one-off processes separate admin tasks from rest of the application.


OCR of Images #
2023-05-16_18-03-04_screenshot.png #

Production Configuration Settings Staging - l - Q/A Source Code Repository Provisioning Scripts DevSecOps <I> Source Code Developer
2023-05-16_18-03-20_screenshot.png #

"dependencies":( "apollo-link"A1.2.11, rapolloHink-ws-m.017: apollo-server-724.0 "graphg".A14.2.1", graphgHtag".02101 lodash".04.17.11", "node-fetch"A2.3.0" My Application's Source Code uses- "subscriptions-transport-Ws"."A0.9.16", "uuid"."A3.3.2", "ws"."A6.2.0" 3, devDependencies"( "chai"."A4.2.0", "faker"."A4.1.0", graphgl-requesr-91.82; "mocha"."A5.2.0", "supertest".A3.4.2"
2023-05-16_18-03-30_screenshot.png #

APP PORT=3030 DB URLFhttp://aydb:3306 BROKER URLEhtEp://kafka:9092 uses. MyApp DEBUG=true Environment Variables
2023-05-16_18-03-49_screenshot.png #

Backing service mongoDB MyApp Backing service RabbitMQ Y
2023-05-16_18-04-00_screenshot.png #

Build Release Run 6 git deploy create deploy Source Code Repository Quay Container export container Podman Registry Podman container Deployment Unit apply Provisioning provision Scripts Configuration Settings CI/CD
2023-05-16_18-04-16_screenshot.png #

Process A Database Process B Process C Process D Database Database Database
2023-05-16_18-04-27_screenshot.png #

http:lca dns>:3030 http:ll<another dns>:4040 http:llcsome other_ dns>:5050 Service A Service B Service C
2023-05-16_18-04-42_screenshot.png #

Business Service Web Server Data Storage Business Service Web Server Data Storage Data Storage Web Server Business Service
2023-05-16_18-05-32_screenshot.png #

Build Release Run a e git create Source Code Repository V1 Deployment unit deploy deploy Quay Container export Registry - A provision- @ apply O V1 Configuration Settings export V1 Provisioning Scripts Production V1 Deployment Unit deploy create never deploy from development to production directly V2 Deployment unit V2 Deployment Unit deploy provision- apply V2 Provisioning Scripts Development V2 Configuration Settings CI/CD
2023-05-16_18-05-44_screenshot.png #

Event Store consumes- (Logger) Interested event event event event consumes- Service A Interested Service B consumes-
2023-05-16_18-06-06_screenshot.png #

Build Release orders Run Ogit deploy rexport- Source Code create deploy Artifact provision- Repository Repository apply provision Provisioning Scripts orders Configuration Settings deploy create dataSeeder export dataSeeder apply Configuration Settings
2023-09-28_12-47-44_screenshot.png #

12-Factor Methodology for Developing N M. - V a AMinnnnn Microservices-based Applications LAI Codebase Dependencies Configuration Backing services Build, release, and run Processes Port binding Concurrency Development and Admin processes Disposability Logs production parity