Intermediate LevelSoftware Engineering Principles
What are the core principles of The Twelve-Factor App methodology for cloud-native software?
❓ Interview Prompt: Explain The 12-Factor App methodology: Codebase, Dependencies, Config, Backing services, Build/Run/Release, Stateless processes, Port binding, Concurrency, Disposability, Dev/Prod parity, Logs, Admin processes.
The Twelve-Factor App methodology defines architectural best practices for building scalable, cloud-native web applications:
Key Factors:
1
Codebase: One repository tracked in revision control, many deploys.
2
Config: Store environment configuration in environment variables (never hardcoded!).
3
Stateless Processes: Execute app processes as stateless, share-nothing processes (store session state in Redis).
4
Port Binding: Export services via self-contained port binding ('app.listen(3000)').
5
Disposability: Fast startup and graceful shutdown ('SIGTERM' handling).
Code Implementation Example
typescript
import express from 'express';
const app = express();
// Factor III (Config in Env) & Factor VII (Port Binding)
const PORT = process.env.PORT || 3000;
const server = app.listen(PORT, () => console.log('App running on port \\${PORT}'));
// Factor IX (Disposability: Graceful Shutdown)
process.on('SIGTERM', () => {
server.close(() => console.log('Process terminated gracefully'));
});💡Implementing Twelve-Factor Config and Disposability handling in Express.
🎯 Interview Key Takeaway
Adhere to Twelve-Factor principles for cloud-native applications: store config in environment variables and build stateless, disposable processes.
#12-Factor App#Cloud Native#Architecture#Intermediate
Back to all Software Engineering Principles Questions→