Skip to content

  • Home
  • Core Java
    • Write Your Own Immutable Class In Java
    • Write Your Own Singleton Class In java
    • Java Concurrent Package
    • Java Stream Revisited
    • Print odd and even numbers using thread
    • SOLID principles
    • Comparable Vs Comparator
    • Sort HashMap/TreeMap based on value
    • Deep and Shallow Copy in Java with examples
    • Find the frequency of each character in a String
    • How to avoid duplicate Employee objects in HashSet ?
  • Spring
    • Loose Coupling & Dependency Injection
    • Bean Scope
    • Spring Bean Lifecycle
    • IoC Container Vs Application Context Vs Bean Factory
    • @Component Vs @Service @Repository Vs @Controller
    • How to read properties file in Spring
    • Spring AOP (Aspect Oriented Programming)
    • @Component Vs @Bean in Spring
    • Exception Handling in SpringBoot
    • XML configuration Vs Annotations configuration in Spring
    • Spring Data JPA
    • Spring Data REST
  • Spring Security
    • Spring Security with Form, Basic and JWT
    • Security Configuration in Spring Boot Apps
    • Security Protocols & Frameworks
    • Okta OAuth 2.0 SSO with Springboot
    • Spring Boot 2.x Security using Username Password
    • Spring Boot 2.x Security using JWT
    • Spring Boot 3.x Security using Username Password
    • Spring Boot 3.x Security using JWT
  • Microservices
    • Spring Cloud Config (Server & Client)
    • Spring Boot Microservices Tutorial (Part 1 of 2)
    • Spring Boot Microservices Tutorial (Part 2 of 2)
    • Circuit Breaker – Resilience4j
    • The Twelve-Factor App Principles
  • Event Driven Microservices
    • What is Event Driven Microservice ?
    • What is Saga Design Pattern ?
    • What is CQRS Design Pattern ?
  • Spring AI
    • ChatGPT API + SpringBoot Integration
  • Hibernate & JPA
    • JPA vs JDBC
    • CRUD Example Using Spring Boot JPA + H2 + Gradle
    • MongoDB Atlas With Spring Boot Example
    • Transaction Management
    • Relationships in JPA & Hibernate
    • Hibernate First & Second Level Cache
    • Spring Boot Flyway Postgres
  • DevOps
    • What is Devops ?
    • Docker
    • Kubernetes (K8S)
    • Jenkins
    • Infrastructure As Code
  • Functional Programming
    • Functional Programming Vs Structured Programming
    • Java 8 Programs For Interview
    • Predicate, Function, Consumer and Supplier in Java 8
    • Sort a List having Employee objects using Java 8
    • Find Employee from List using Java 8
  • AWS
    • AWS S3
    • AWS EC2
    • EC2 Solutions Architecting
    • How to create an EC2 instance ?
    • How to connect to AWS EC2 instance ?
    • Deploy application to AWS
    • AWS Lambda Java Tutorial
    • Spring Cloud Functions
    • How to Start/Stop AWS ECS automatically using Java Spring?
    • Container Solution in AWS
    • AWS SQS, SNS, MQ and Kinesis
    • Databases in AWS
    • AWS VPC: Peering, Endpoint, VPN, Gateways- Internet, NAT, DX
    • Machine Learning in AWS
    • Storage Solutions in AWS
    • AWS ASG (Auto Scaling Group)
  • AWS Certifications
    • SAA-C03
      • Design Cost-Optimized Architectures
    • AWS Certified Solution Architect-Associate
      • Question 1
  • Kafka
    • Apache Kafka
    • Kafka Producer & Consumer Example Using Spring boot & Conduktor
  • Angular
    • Angular Tutorial – Part 1
    • Angular Tutorial – Part 2
  • Miscellaneous
    • How to add a project to Git/GitHub/GitLab
    • How to Clone a project from Git/GitLab using Git Bash
    • How to query Oracle tables based on some date ?
    • How to highlight text in WordPress ?
    • How to add Page Jumps in WordPress page ?
  • Interview Preparation
    • Core java interview questions
    • Java Threads Interview Questions
  • Contact Me
  • Toggle search form

The Twelve-Factor App Principles

The 12 factor app principle is a methodology or set of principles for building the scalable and performant, independent, and most resilient enterprise applications. It is very popular as it aligns with the Microservice principle.

1. Codebase:

One codebase tracked in version control, many deploys.

2. Dependencies:

Explicitly declare and isolate the dependencies.

From a java project perspective, think of Pom.xml, where you can declare all your dependencies.

3. Config:

Store config in the environment.

4. Backing Services:

Treat backing services as attached resources.

Backing services like – Database, Message Brokers, or any other services the app uses should be treated as an attached resources.

5. Build, Release, Run:

Strictly separate build and run stages.

6. Processes:

Execute the app as one or more stateless processes.

Any session data should not be stored in the app itself, rather it should be saved in a database.

7. Port Binding:

Export services via port binding.

Web apps generally need a container to get executed, for eg., a java app need Tomcat to run the application. As per the twelve-factor app principle your app should be self reliant and does not rely on runtime injection of a webserver into the execution environment to create a web-facing service. The web app exports HTTP as a service by binding to a port, and listening to requests coming in on that port.
In a local development environment, the developer visits a service URL like http://localhost:5000/ to access the service exported by their app. In deployment, a routing layer handles routing requests from a public-facing hostname to the port-bound web processes.
In short, this is all about having your application as a standalone instead of deploying them into any of the external web servers. Spring boot is one example of this one. Spring boot by default comes with embedded tomcat, jetty, or undertow.

8. Concurrency:

Scale out via the process model.

We should opt for horizontal scaling instead of vertical scaling. By adopting the containerization, applications can be scaled horizontally as per the demands.
Vertical scaling : Add additional hardware to the system.
Horizontal scaling : Add additional instances of the application.

9. Disposability:.

Fast startup and graceful shutdown

Using containerization the applications can be started or stopped quickly,

10. Dev/Prod Parity:

Keep development, staging and production environment as similar as possible.

11. Logs:

Treat logs as event streams.

12. Admin Processes:

Run admin/management tasks as one-off processes.

While deploying an app to an environment, there are some admin/management processes that has to be executed prior to that. These can be data migration scripts, One-Off DB scripts, etc. Twelve-factor principle advocates for keeping those admin/management processes as part of the codebase, so that it will also follow the same process that is defined for your app codebase.

Copyright © 2025 .

Powered by PressBook Blog WordPress theme