Microservices Mastery
Lesson 2 of 30 7% of course

The 12-Factor App Methodology for Cloud-Native Apps

16 · 8 min · 5/23/2026

Sign in to track progress and bookmarks.

The 12-Factor App Methodology

Created by the engineers at Heroku, the 12-Factor App is a set of best practices for building modern, cloud-native applications that are portable, resilient, and ready to scale in environments like Azure, AWS, or Kubernetes.

1. Key Factors for .NET Developers

  • Config: Store configuration in the **Environment**, not in the code. Never hardcode connection strings!
  • Backing Services: Treat databases, caches, and message brokers as attached resources. Your app shouldn't care if it's talking to a local Docker DB or a Cloud-managed SQL.
  • Statelessness: App processes must be stateless and share nothing. State belongs in a backing service (like Redis). If a server crashes, another should pick up without the user noticing.
  • Port Binding: The app should be self-contained and export services via port binding (e.g., Kestrel listening on port 8080).

2. Dev/Prod Parity

Factor 10 states that your local environment should be as close as possible to production. This is why we use Docker Compose—to ensure the exact same DB version and OS version follow the code from the developer's laptop to the production cluster.

4. Interview Mastery

Q: "Why is 'Statelessness' the most important of the 12 factors for scaling?"

Architect Answer: "Because it allows for **Elasticity**. If your app stores user sessions in the RAM of the local server, you are stuck with that server. If you add a second server, the user might hit server B and 'lose' their login. By moving state to a backing service like Redis or a Database, any server instance can handle any incoming request. This allows you to scale from 1 instance to 10 instances in seconds without killing active user sessions."

Test your knowledge

Quizzes linked to this course—pass to earn certificates.

Browse all quizzes
Microservices Mastery

On this page

1. Key Factors for .NET Developers 2. Dev/Prod Parity 4. Interview Mastery
1. Distributed Systems Fundamentals
Monolith vs Microservices: When to migrate? The 12-Factor App Methodology for Cloud-Native Apps Database Per Service: Handling distributed data consistency
2. Containerization & Orchestration
Docker Essentials: Building efficient .NET images Docker Compose: Orchestrating a multi-service environment Kubernetes Architecture: Pods, Services, and Deployments K8s ConfigMaps & Secrets: Managing environment variables Helm Charts: Packaging your microservices for K8s
3. Service Communication
Synchronous vs Asynchronous Communication: Pros and Cons REST APIs in a Microservices World: Best Practices Mastering gRPC: High-performance binary communication API Gateways: Implementing Ocelot for single-entry access BFF Pattern: Backend-for-Frontend (Mobile vs Web)
4. Event-Driven Architecture
Message Brokers: Introduction to RabbitMQ & Azure Service Bus Pub/Sub Pattern: Implementing MassTransit for .NET The Outbox Pattern: Ensuring 100% data consistency Dead Letter Queues: Handling message failure gracefully Distributed Transactions: The Saga Pattern (State Machines)
5. Resilience & Scalability
Distributed Caching with Redis: Optimizing global state Service Discovery: IdentityServer4 & Consul Load Balancing: Nginx vs Ingress Controllers The Sidecar Pattern: Offloading cross-cutting concerns
6. Observability & Security
Distributed Logging with Serilog & SEQ Distributed Tracing: OpenTelemetry & Jaeger Health Checks: Monitoring system vitals in real-time OAuth2 & OpenID Connect: Centralized Identity (AuthN/AuthZ) Rate Limiting & Throttling: Protecting your services
7. Advanced Cloud Topics
Infrastructure as Code (IaC): Introduction to Terraform CI/CD Pipelines for Microservices (GitHub Actions/Azure DevOps) C# Architect Interview: Microservices & System Design Focus