Building Multi-Tenant SaaS Application on AWS


SaaS, one of the three mainstays of cloud computing, is gaining ground globally. By 2021, the market segment is expected to reach US$113.1 billion, almost twice its total revenue of US$58.8 billion in 2017. Businesses looking for the latest IT capabilities and delivery model for their products are increasingly adopting SaaS. The centrally managed software is helping them reduce application cost, bringing in more flexibility for the in-house operations as well as the users, and making collaboration faster under the same software suite. Further, it is enabling enterprise users to save data intelligently without having to worry about safety. To put it simply, SaaS is playing an important role in increasing the productivity of organizations through data optimization.

Problem introduction:

One of our customers based in Nordics who is a provider of SaaS applications for the oil and gas industry recently approached us with an interesting problem. To give an idea of their field of operations: they work extensively with large data sets to solve complex problems for their customers. Their applications use Machine Learning, Data Science and AWS Services to solve some of the most difficult tasks, accurately for their customers. They wanted us to build a multi-tenant SaaS application for them on AWS.

Now, there are certain limitations of cloud-SaaS application that bother almost every user throughout the usage. We had to understand what specific problems the company was facing to be able to provide the right solution in the right way. After a prolonged discussion with the CTO of the company, we formed the below understanding of the problem situation:

  • New customer onboarding was taking too long, sometimes extending up to 3-5 days.
  • They had to use separate EC2 instances for different customers. As a result, the infrastructure cost was rising uncontrollably.
  • Disaster recovery was proving to be too costly as there was no proper infrastructure in place.
  • The dependence on EC2 was growing.

Based on the problem analysis, we formulated a set of objectives which would guide us in the solution implementation:

  1. Make application multi-tenant and at the same time, scalable
  2. Avoid insecure Docker Compose environment variables
  3. Move production out of Docker Compose
  4. Remove a single point of failure, one EC2 instance running all of the application and its components

A well-architected framework of AWS assists cloud technologists to build the most secure, high-performing, hardy, and efficient infrastructure for their applications. This well-architected framework has five pillars that help the cloud architect produce a stable and efficient system. They are:

  1. Operational excellence
  2. Security
  3. Reliability
  4. Performance efficiency
  5. Cost optimization

We implemented a solution by utilizing these five principles of AWS’ well-architected framework:

  • We converted web product application to web-based multi-tenant SaaS application
  • Used a managed service Elastic Container Service (ECS) instead of an EC2 to run Docker
  • Converted the entire infrastructure into code through Terraform

For the solution, we used the following tools, platforms, services and programming languages:

Public cloud platform – Amazon Web Services (AWS).

There are many benefits of building SaaS on AWS. The tools and services range available on AWS is vast and it helps SaaS providers to reduce their time-to-market significantly. The pace of innovation also provides the companies with new capabilities and services to enhance the features of the solutions, their cost, and management profile. The combination of service innovations at AWS and minimization of operational overheads eventually makes SaaS organizations much more agile. They also benefit from improved uptime, dynamic scaling mechanisms, better data security (AWS provides enterprise customers a data center and network architecture), and enhanced reach globally.

To note: AWS cloud is continuously expanding its availability zones. Right now, it spans 64 zones within 21 geographic regions!

We visualized a similar digital transformation for our client when we implemented the solution.

The following services were prominently used:

  1. Elastic Container Service
  2. Lambda
  3. API Gateway
  4. CloudWatch Logs
  5. Key Management Service
  6. Simple Storage Service

MongoDB Atlas – Fully-managed global cloud database service for the public cloud platform (AWS).

Containers for Node.js and Python

Node.js, Python

Upon successful implementation of the solution and subsequent testing, we were happy to see that our client was getting benefited in the following ways:

  1. New customer on-boarding time was significantly less- only 4 hours as opposed to 3-5 days it was taking previously.
  2. The use of the multi-tenant model could bring down the cost of infrastructure. Separate EC2 instances were no longer being required for different customers.
  3. There was a disaster recovery system in place. It was now possible to recreate an entire infrastructure in less than an hour in the event of a disaster, thus reducing the disaster recovery time significantly.
  4. A number of functions could be converted to serverless using Lambda. It reduced the dependency on an EC2 instance.
  5. It was now possible to store configurations and other secrets in Systems Manager Parameter Store and encrypted using AES 128-bit encryption.

All these could be achieved in addition to the set objectives within the pre-decided time frame. And that added to our satisfaction.

The multi-tenancy SaaS application would help the customer in many ways. Firstly, software development and maintenance costs would now get shared. With this architecture, they would be able to run one instance of its application on one instance of a database and provide web access to multiple customers without sharing or seeing each other’s data.

At Loves Cloud, we are constantly leveraging the power of various public cloud computing platforms along with multiple open source software solutions to automate, optimize, and scale workloads of our customers. To learn more about our services aimed at the digital transformation of your business, please visit https://www.loves.cloud/ or write to us at biz@loves.cloud.