Micro Service 12 Factor
The Twelve-Factor App is a methodology for building software-as-a-service apps
- Codebase: One codebase tracked in version control, many deploys. A single codebase is shared across all environments, but there may be multiple deployments (e.g., staging, production).
- Dependencies: Explicitly declare and isolate dependencies. Applications should not rely on implicit dependencies and should use dependency management tools to declare all dependencies explicitly.
- Config: Store config in the environment. Configuration that varies between deploys (such as database credentials) should be stored in environment variables.
- Backing Services: Treat backing services as attached resources. Resources like databases, messaging systems, and caches should be attached and detached from deploys without changing the app’s code.
- Build, Release, Run: Strictly separate build and run stages. A codebase goes through a build stage to produce a release, which is then run in execution environments.
- Processes: Execute the app as one or more stateless processes. Stateless and share-nothing processes ensure the app can scale out by adding more processes.
- Port Binding: Export services via port binding. The application should be self-contained and expose services by binding to a port, rather than depending on the runtime environment to provide network services.
- Concurrency: Scale out via the process model. The app can handle various workloads by running multiple processes.
- Disposability: Maximize robustness with fast startup and graceful shutdown. Processes should start quickly and shut down gracefully to enable rapid deployment and scaling.
- Dev/Prod Parity: Keep development, staging, and production as similar as possible. This minimizes the chances of bugs being environment specific.
- Logs: Treat logs as event streams. Applications should not manage log files but should send their log output to the environment's centralized log management system.
- Admin Processes: Run admin/management tasks as one-off processes. Administrative tasks, like database migrations, should be run in an isolated environment identical to the application’s execution environment.
19 Microservices Design Patterns for System Design
- Service Registry
- API Gateway
- Circuit Breaker
Purpose: Prevents cascading failures by stopping requests to failing services.
Benefits:
- Increases system resilience.
- Avoids overloading failing services.
Tools: Resilience4j, Hystrix (deprecated).
- Saga Pattern
Orchestration: WC Architecture
Choreography: MC Architecture
Purpose: Manages distributed transactions across services.
Benefits:
- Ensures eventual consistency.
- Handles rollback through compensating actions.
Types: Orchestration (central control), Choreography (event-driven).
- Database per Service
- Command Query Responsibility Segregation (CQRS)
- Retry
- Data Sharding
- Event Sourcing
- Async Messaging
- Consumer-Driven Contracts
- Sidecar

- Backends for Frontends (BFF)
- Shadow Deployment
- Transaction Outbox Pattern
Purpose: Prevents cascading failures by stopping requests to failing services.
Benefits:
- Increases system resilience.
- Avoids overloading failing services.
Tools: Resilience4j, Hystrix (deprecated).
Orchestration: WC Architecture
Choreography: MC Architecture
Purpose: Manages distributed transactions across services.
Benefits:
- Ensures eventual consistency.
- Handles rollback through compensating actions.
Types: Orchestration (central control), Choreography (event-driven).

Transaction Outbox Pattern
No comments:
Post a Comment