Organizations are moving to the SaaS (Software-as-a-service) delivery model to achieve optimized cost, operational efficiency and overall agility in their software business. SaaS helps to onboard their customers (tenants) into a centrally hosted version of the solution, and manage them via a single pane of glass. These SaaS solutions allow the underneath infrastructure components to be shared across tenants, while demanding mechanisms that can implement the multi-tenancy in the architecture to preserve overall security, performance and other non-functional requirements demanded by the use-case. Often, these strategies and their implementation heavily depend on the underneath technologies and AWS managed services that are being used.
This github solution provides code samples, configurations and best practices that help to implement multi-tenant SaaS reference architecture leveraging Amazon Elastic Container Service (ECS).
The objective here is to dive deeper into design principals and implementation details in building ECS SaaS reference solution covering necessary technical aspects. We will discuss SaaS control plane functionalities with shared services such as tenant onboarding, user management, admin portals, along with the SaaS application plane capabilities such as ECS compute isolation strategies, request routing at scale, service discovery, storage isolation patterns, API throttling and usage plans, and different ways to ensure security and scalability.
The following diagram shows the high-level architecture of the solution that outlines the core components of ECS SaaS. It is a tier-based SaaS, and the three tiers represent three different tenant isolation strategies using Amazon ECS. This would help SaaS providers to have a wide range of technical options to model their SaaS solution based on their tiering requirements.
Fig 1: ECS SaaS - High-level infrastructure
This reference architecture adopts the latest AWS SaaS Builder Toolkit (SBT) that AWS SaaS Factory has developed. SBT helps to extend the SaaS control plane services such as tenant onboarding, off-boarding, tenant and user management, billing, etc seamlessly into the solution. It also provides an event-based integration to the ECS application plane that enables bi-directional communication for SaaS operations. Read more about AWS SBT here.
This solution can be deployed via an AWS Cloud9 environment on your AWS account, or directly from your laptop.
If you are using Cloud9, make sure to use Amazon Linux 2023
AMI for the EC2 with at least t3.large instance size. Also, increase the volume size of the underlying EC2 instance to 50 GB (instead of default 10 GB) using this script ./scripts/resize-cloud9.sh
- This is to make sure that you have enough compute and space to build the solution.
To deploy this ECS SaaS reference solution, you can run the below commands. Replace the admin_email
with a real email address that will be used to create an admin user in the solution, and to share the admin credentials that allow to perform administrative tasks such as onboarding new tenants.
git clone this_repo_url
cd saas-reference-architecture-ecs/scripts
./build-application.sh
./install.sh admin_email
Note that, build-application.sh
builds docker images of sample SaaS application with order, product & user microservices and pushes to Amazon ECR.
And, install.sh
deploys the following:
controlplane-stack
which provisions
coreappplane-stack
which provisions
shared-infra-stack
, which provisions
tenant-template-stack
, which provisions
tenant-template-basic
: ECS cluster and ECS service Order, Product, and User microservices for the Basic tier.tenant-template-advanced
: ECS cluster for the Advanced tier (Microservices are installed exclusively when a tenant onboard.)Run the following script to clean up reference solution resources from your AWS account. Please make sure that jq JSON processor installed in your environment before invoking below script.
cd scripts
./cleanup.sh
This library is licensed under the MIT-0 License. See the LICENSE file.
See CONTRIBUTING for more information.