Implementation of The 12 Factors App Methodology with AWS Cloud for a SAAS Product - Part 3
Connection of 12 Factors App Methodology with AWS Cloud - Part 3

Implementation of The 12 Factors App Methodology with AWS Cloud for a SAAS Product - Part 3

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

4. Backing services

5. Build, release, and run

6. Processes

7. Port binding

8. Concurrency

9. Disposability

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.

Implementation of The 12 Factors App Methodology with AWS Cloud for a SAAS Product - Part 1

Implementation of The 12 Factors App Methodology with AWS Cloud for a SAAS Product - Part 2

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:

Amazon Machine Image AMI build


  • EC2 - runs the application as fully backed AMI (Amazon Machine Image) with EC2 image builder or?
  • ECS/EKS - executes packer as an automated build system to manage the creation of images for containers as like docker containers starting and running in seconds
  • AWS Lambda - being a dedicated provisioned concurrency feature that is ready to be executed within milliseconds
  • AWS X-Ray - traces the lambda functions and keeps records with details about lambda function invocation and execution

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 time gap: A developer may write code for an application that takes days, weeks, or even months to go into production.
  • The personnel gap: Developers team write code and operations team deploy it.
  • The tools gap: Developers may be using a stack like SQLite, Nginx, and OS X, where the production deployment uses MySQL, Apache, and Linux.

?The twelve-factor application must be designed for continuous deployment to minimize the gaps between development and production by applying the followings:

  • Installed and run safely in the production environment by engaging the developers who write code into the deployment and monitoring its behaviour in production
  • Could be minor differences among ENV configurations?
  • Keeping the same tools for development and production as much as possible

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

  • AWS CloudFormation

- 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

AWS CloudFormation Cloud Development Kit


  • AWS Cloud Development Kit (CDK)

- 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

AWS SAM Serverless Application Model


  • AWS Serverless Application Model (AWS SAM)

- 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

AWS SAM Serverless Application Model Best Practice


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 CloudWatch Logs for AWS Lambda as well as other services like EC2
  • Centralized logs storage solutions like Amazon S3, ELK stack in Amazon ElasticSearch
  • Searching and analysis approach solutions like Amazon Athena, CloudWatch Logs Insights
  • Real-time approach analysis like Kinesis family for buffering, transforming and merging streaming data of logs such as?

- Amazon Kinesis Data Streams

- Amazon Kinesis Firehose

- Amazon Kinesis Streams

API Gateway provides two different methods for getting log information:

  • Execution logs having errors or execution traces
  • Access logs

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:

  • Running database migrations?
  • Running a console (also known as a REPL shell) and it’s syntax varies on different languages
  • Running one-time scripting committed to the application’s repo

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:?

  • AWS System Manager for the configuration management,?
  • AWS SAM with CloudFormation templates, and CodeBuild CI/CD process in case of #serverless application.?
  • Amazon CloudWatch events for the scheduling feature and AWS Lambda, AWS SSM Agent in case of recurring administrative tasks
  • ECS scheduled task by using a cron-like schedule to run tasks at set intervals

The following architecture diagram summarizes how the Systems Manager works.

AWS Systems Manager how it works


  1. Access Systems Manager - Using one of the options available for systems manager
  2. Choose a Systems Manager capability - IT administrators and DevOps engineers use capabilities for managing their apps and resources
  3. Verification and processing - Verifying the permission of IAM users, groups or roles to perform the actions
  4. Reporting - Sending status details that are generated by SSM Agent, and other AWS services
  5. Systems Manager operations management capabilities?- Providing operational insights using Explorer, OpsCenter, and Incident Manager and offering the automated remediation plan when any troubleshoot occurs

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

How to Apply the Twelve-Factor App Methodology to Serverless Applications

How to Develop Twelve-Factor Apps using Amazon ECS and AWS Fargate

AWS SAAS Factory Program

要查看或添加评论,请登录

Md. Mostafa Al Mahmud的更多文章

社区洞察

其他会员也浏览了