My Top 10 learnings: Building multi-tenant, SaaS, micro-services system for diverse tenants
Designing and building a multi-tenant SaaS system to support diverse tenants is a challenging task. Added to that, with a micro-service architecture, it makes the system difficult to maintain. We at AskSid, have been building (it’s never “built”) such a system, which supports tenants of different kinds along with their multiple markets and languages. The velocity of customizations and enhancements is very high and has been increasing while the quality stays world class and uncompromisable.
The 2 biggest challenges we face in building such systems are
1. Cost of provisioning a new tenant
Once tenant’s data and integrations are available, onboarding of tenant may require changes at multiple places and human effort needs to be expended for manual activities. This introduces some delays before the system actually starts serving the tenant.
2. Incapability or cost of customizations
As the cliched saying goes, “Customer is the King”. More often than not, tenants request customizations on the top of existing services offered. In such situations, the system may not be capable or may have to bear the cost in terms of time and effort to accommodate the customization.
It is this constant trade-off between speed and cost that makes it difficult at times to architect, provision, and run such a system.
From the perspective of an ideal SaaS system, it is practically impossible to build a 100% reusable multi-tenant system which can accommodate tenants of different kinds. Hence, we need to take a hybrid approach, where some parts of the system are completely reusable and other parts handle the tenant-specific functionalities.
Here are some practices we can follow, to increase the flexibility, velocity, and quality of SaaS system development:
1. Identify domains and form verticals of your tenants
Data and business logic are what software systems comprise of. The data model and business logic of the system differ tremendously per domain of tenant. To serve tenants from different domains, it is necessary to have your data model and business logic written for domains if not for each tenant.
2. Flexible data models
Data modeling is the first and most important step in software designing. In multi-tenant systems, you need to mold multiple tenants’ data into a single model. It also should allow future customization and new features. Flexibility should be kept in mind while modeling the data.
3. Containerization and CI/CD
Containerization of apps and CI/CD has become a de facto standard in micro-service based systems. They tremendously improve the efficiency of development by speeding up the testing and reducing the probability of issues occurring due to external elements.
4. High automation
Automation is the key to increase the velocity of change and maintain world-class quality. Any human-involved and repetitive activity becomes the candidate for getting automated. Keep a watch for such scope of automation and act whenever you spot any opportunity.
5.Externalizing and centralizing the configurations
Even the tenants of the same domain may have differences in system behaviors. To support such differences, having just the constants in your configuration file is not sufficient. Any change-prone behaviors, feature switches or tuning values should be moved to configuration files. To achieve faster releases, move your configurations out of your container images. Centralizing all the configuration at the single place will help developers get a single view of all configurations.
6.Admin apps for you and tenants
Have an Admin app, with a bare minimum UI (jazz it up over time), which can be used for anything and everything that is needed to be done by an admin to keep the system running. This can include user management, tenant management, job management, system’s maintenance activities etc.
Enabling your customers to do self-service is a key goal of any SaaS system and factoring admin ease of use upfront can go a long way in increasing adoption of your system.
7. Cloud IaaS & Container orchestration for auto-scaling and deployments
Using cloud VMs and container orchestration tools like Kubernetes reduces the DevOps efforts significantly. It enables the system to auto scale in the time of load and simplifies micro-service to micro-service communication with internal DNS capabilities.
8. Data transformations and integrations
Provisioning of new tenants brings with it the need of integration with their own systems and data in unique structure and formats. The data need to be fetched and transformed to make it usable for your multi-tenant system. Tenant-specific customizations and transformation into the tenant-agnostic model can be carried out here so that the core multi-tenant components work on single data model.
9.Good isolations for tenant’s data
In multi-tenant systems, there are multiple ways you can store tenant’s data with the ability to differentiate them by the tenant. These ways are multiple databases, multiple schemas, and discriminator fields. The isolation required to have freedom of different schemas, backups, access controls can be provided only by the first 2 approaches. Apart from databases, in brokers, caches as well, the highest level of isolation should be chosen for efficiency.
10. High monitoring and tests
Multi-tenant SaaS systems generally grow large (with respect to the number of components) and become complex to maintain over time. This can be made easier if admins are given the ability to track everything that is happening in the system, in both business and technical aspects. Any significant business events should be tracked by raising such events to a broker. Technical events such as errors, performance, resource utilization etc. can be tracked by means of application logs or any monitoring solutions. Dashboards provide visualizations and alerts which help admins identify, debug critical issues, derive patterns from user behaviors in real time. Automated tests for user interfaces and integrations help identify issues early
To sum up, make design decisions & tradeoffs on common and tenant-specific customizations to hosted apps, data models, and code logic for your tenants with the goal to have the higher velocity for tenants provisioning, ability to customize without impact, and quality in delivering services.
Interested to learn more on how we are building such a world-class and complex system at AskSid.ai? Reach out to us at email@example.com and let’s start a conversation.
Author: Bhushan Vadgave (firstname.lastname@example.org)