Implementation of The 12 Factors App Methodology with AWS Cloud for a SAAS Product - Part 3
Md. Mostafa Al Mahmud
Sr. Software Engineer | AWS Community Builder | AWS Certified | SRE | Serverless | Microservice | NodeJS | TypeScript | JavaScript | Tech Speaker
This article helps the developers, programmers, solutions architects directly to integrate a #saas application following the 12 Factor App methodology in the #aws cloud architecture and the DevOps guys to maintain this type of apps under AWS platform although this methodology is absolutely applicable to several cloud platforms as well.
The Twelve-Factor App principles, written by Adam Wiggins , co-founder of Heroku , are listed below that are should be implemented while building a #saas product.
1. Codebase
2. Dependencies
3. Config
6. Processes
7. Port binding
8. Concurrency
10. Dev/prod parity
11. Logs
12. Admin processes
For the first 8 factors, I discussed on part 1 and part 2. Links are given below.
Let’s discuss the last 4 factors as disposability, dev/prod parity, logs and admin processes shortly and communicate with the related AWS services that serve The Twelve-Factor App methodology's purposes actually.
9. Disposability (Maximize robustness with fast startup and graceful shutdown)
The twelve-factor application’s processes are disposable, meaning that they can be started or stopped smoothly at any time when needed. This facilitates minimizing the bootstrapping time so as fast elastic scaling, config changes, rapid deployment of codebase, continuity of production deployments without any hassle and contrarily in case of failure, returns the current task to the work queue.
In AWS, we can minimize the time needed to launch an application in several ways relied on the service itself as follows:
After the implementation of AWS cloud services, now the app is architected to handle unexpected situations, undesirable terminations.
The official docs for AWS Lambda and AWS X-Ray
For further details on AMI design, check this pdf AWS AMI Design
For AMI builder, see How to Create an AMI Builder with AWS CodeBuild and HashiCorp Packer
10. Dev/Prod Parity (Keep development, staging, and production as similar as possible)
There are three areas of gaps mainly between development and production as summarized below:
?The twelve-factor application must be designed for continuous deployment to minimize the gaps between development and production by applying the followings:
In this regard, AWS provides us the Infrastructure as Code (IaS) feature that serves the purposes of dev/prod parity principles. For ths implementation, we can use
- a purpose-built service for creating and configuring AWS services.
- a model, provision, and manages AWS and third-party resources by treating Infrastructure as Code.
- a domain-specific declarative language for their resource definition with configurable syntax that leverages the transformation mechanism.
- capable of CRUD sibling? environments frequently
- a framework for defining cloud infrastructure in code and provisioning it through AWS CloudFormation
- built with high-level, object-oriented abstraction that automatically provide certain, secure defaults for your AWS resources, defining more infrastructure with less code
领英推荐
- applicable with various languages like #typescript, #javascript , #python, #java, #csharp
- a Lambda-like execution environment that helps applications locally to be built, tested, and to be debugged applications defined by SAM templates?
- easier resource configuration with a simplified syntax
Now all the deployments of the application (development, staging, production) use the same type and version of each of the backing services as well.
For the AWS CloudFormation docs, got to this blog AWS CloudFormation
Also, this blog is helpful AWS Serverless Application Model (AWS SAM) to build a serverless application.
11. Logs (Treat logs as event streams)
Logs are the stream of aggregated, time-ordered events representing the sequence of events collected from the output streams of backing services like application instances and all running processes.
The twelve-factor application produces, processes and stores the app events to a stream by a dedicated logging library or open-source log routers like Logplex and Fluentd. Also, the app never manages itself with routing or storage of its output log stream.
In AWS, we have several options to implement this twelve-factor app principle with the ability to export logs to other services such as:
- Amazon Kinesis Data Streams
- Amazon Kinesis Firehose
- Amazon Kinesis Streams
API Gateway provides two different methods for getting log information:
Both are also made available in CloudWatch Logs. For more information, see Setting up CloudWatch logging for a REST API in API Gateway
If you want to build a log analytics solutions, this blog will definitely help you to start on time Build a Log Analytics Solution
However, implementing those approaches, now we can say that the app is capable of finding specific events in the past, graphing trends at large-scale, and getting the alert and notification based on conditions.
12. Admin Processes (Run admin/management tasks as one-off processes)
The last and final factor, admin process formation is a list of processes that are used to do the app’s administrative tasks as it runs. Separately, developers sometimes will wish to do as one-off administrative or as maintenance tasks such as:
Twelve-factor app rules strongly favour languages which provide a REPL shell out of the box, and which make it easier to run one-off scripts.
AWS provides the configuration management tools and services as like below:?
The following architecture diagram summarizes how the Systems Manager works.
AWS Systems Manager is a collection of capabilities to help the developers manage the applications and its infrastructure running in the AWS Cloud.
Here is the official docs of AWS Systems Manager?
The Twelve-Factor App methodology is the twelve best practices that help the developers to decouple components of the app, so that each component can be reusable easily, or scaled up or down seamlessly that is considered nowadays actually as a modern, cloud-native application.?
Above all, I have discussed in this article about the topic at a high level overview and of course different solutions will have different architecture where the cloud service usages are varied based on that architecture. It will help the developers who are building a #saasstartup for brainstorming to create a software architecture.
Please follow me to get more articles in future.
Helpful contents and credit:
The official website of Twelve Factor App is The12 Factor App