API / Microservices
Explain 12-Factor App methodology.
Building microservices using the 12-Factor App methodology ensures consistency, scalability, and ease of deployment in cloud environments.
- Codebase: One codebase tracked in revision control, many deploys. Each microservice should have its own repository to ensure independent lifecycle management.
- Dependencies: Explicitly declare and isolate dependencies. Use tools like Maven, Gradle, or Docker to ensure the app doesn't rely on pre-installed system libraries.
- Config: Store configuration in the environment. Keep credentials and resource handles in environment variables rather than hardcoding them in the source.
- Backing Services: Treat backing services as attached resources. Databases, caches, and queues should be interchangeable via configuration changes without modifying code.
- Build, Release, Run: Strictly separate build and run stages. A build is transformed into a release by adding config, which is then executed in the run environment.
- Processes: Execute the app as one or more stateless processes. Persist any data that needs to survive a restart in a stateful backing service like a database.
- Port Binding: Export services via port binding. The app should be self-contained and listen for requests on a specific port rather than relying on an external web server injector.
- Concurrency: Scale out via the process model. Handle increased load by adding more instances of the process (horizontal scaling) rather than just making one process bigger.
- Disposability: Maximize robustness with fast startup and graceful shutdown. Apps should be able to start or stop at a moment's notice without data loss or long delays.
- Dev/Prod Parity: Keep development, staging, and production as similar as possible. This minimizes "it works on my machine" bugs by using the same backing services across all environments.
- Logs: Treat logs as event streams. The app should write to
stdout, leaving the aggregation and storage of those logs to the execution environment or specialized tools. - Admin Processes: Run admin/management tasks as one-off processes. Scripts for database migrations or maintenance should run in the same environment and against the same release as the app.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
