Location Research Breakthrough Possible @S-Logix pro@slogix.in

Replatforming a Multi-Tenant SaaS Billing Application onto Managed Cloud Infrastructure

Description

This project focuses on replatforming a legacy multi-tenant SaaS billing application from on-premises infrastructure to managed Cloud infrastructure. The application manages customer accounts, subscription plans, invoices, payments, and billing records for multiple organizations. The existing application will be migrated with minimal code changes while managed Cloud services are introduced to improve scalability, availability, security, and operational efficiency.

Aim

To replatform the multi-tenant SaaS billing application onto managed Cloud infrastructure to achieve better scalability, availability, security, and easier management.

Objectives

01 Migrate the existing billing application to managed Cloud infrastructure with minimal changes.
02 Improve application scalability and availability.
03 Protect tenant and billing data through secure Cloud services.
04 Automate infrastructure deployment and application configuration.
05 Implement monitoring, backup, and recovery mechanisms.
06 Reduce operational dependency on on-premises infrastructure.

Application Workflow

01

Tenant and User Access

Process

Organizations and their users log in to the SaaS billing application and access only their own tenant data.

Tools
Nginx PostgreSQL
Implementation

Nginx receives HTTPS requests and forwards them to the billing application. The application authenticates users and identifies their tenant before allowing access.

02

Subscription and Plan Management

Process

Tenants select subscription plans, add customers, and manage their active subscriptions.

Tools
PostgreSQL REST APIs
Implementation

The application validates subscription details and stores tenant, customer, and plan information in PostgreSQL. REST APIs handle communication with external services when required.

03

Invoice Generation

Process

The system generates invoices based on subscription plans, usage, and billing cycles.

Tools
PostgreSQL
Implementation

The application retrieves subscription and customer information, calculates billing amounts, generates invoices, and stores invoice records in PostgreSQL.

04

Payment Processing

Process

Customers make payments for their invoices, and the system updates the payment status.

Tools
REST APIs PostgreSQL
Implementation

The application communicates with external payment services through REST APIs, receives the payment result, and updates the corresponding invoice and transaction records.

05

Billing Reports and Notifications

Process

Tenants view invoices, payment history, billing reports, and receive notifications about payments and upcoming billing events.

Tools
PostgreSQL REST APIs
Implementation

The application retrieves tenant-specific billing data from PostgreSQL and displays reports through the web interface. REST APIs can be used to send notifications to external email or messaging services.

Current Infrastructure

Existing on-premises infrastructure and technologies used before migration.

Existing On-Premises Environment

Database Engine PostgreSQL 14

Stores and manages tenant information such as user accounts, profile settings, activity logs, and other application data on the server.

Operating System Ubuntu Server 24.04 LTS

The application currently runs on an on-premises Linux server.

Process Management Systemd

Starts and manages the application and background services.

Runtime Dependencies Global Pip Packages

Python libraries and other dependencies are installed directly on the server.

Storage Linux ext4

Stores application files, configuration files, and customer-uploaded files such as PDFs and invoices.

Security and Access Linux PAM

Manages SSH access, user accounts, and application permissions.

System Logging Journald

Collects system and application logs for troubleshooting.

Network and Firewall TCP/IP + UFW

The application uses port 8080, while UFW controls allowed network traffic.

Deployment Location On-Premises Linux Server

The application runs on one physical server and shares the server resources between multiple customers.

Target Infrastructure

Cloud-hosted infrastructure and technologies used after migration and modernization.

Cloud-Hosted Modernized Environment

Networking Cloud VPC

Provides an isolated and secure network for the application, database, and supporting Cloud resources.

Cloud Compute Cloud EC2

Provides virtual servers for running the Python application and PostgreSQL database.

Operating System Ubuntu Server 24.04 LTS

Runs on the Cloud EC2 instances.

Process Management Systemd

Starts and manages the Python application, PostgreSQL, and background services.

Runtime Dependencies Global Pip Packages

Required Python libraries and dependencies are installed on the EC2 server.

Database Engine PostgreSQL 14

Continues to manage tenant, customer, subscription, invoice, and payment data in the Cloud environment.

Security and Access Linux PAM

Manages server users, SSH access, and Linux permissions.

System Logging Journald

Collects system and application logs for troubleshooting.

Network and Firewall TCP/IP + UFW

Controls network communication to the application and database services.

Managed File Storage Cloud S3

Stores customer-uploaded files, invoices, PDFs, and reports separately from the EC2 server.

Server Storage Cloud EBS

Provides persistent block storage for the EC2 operating system, application files, and PostgreSQL data.

Network Discovery Nmap

Identifies active systems, open ports, and network services during infrastructure assessment.

Infrastructure Inventory Open-AudIT

Collects information about the existing server hardware and installed software.

System Audit osquery

Checks running processes, users, installed software, and system configuration.

Infrastructure as Code OpenTofu

Creates and manages Cloud resources such as VPC, EC2, EBS, and S3 using infrastructure code.

Configuration Automation Ansible

Configures EC2 servers, installs required software, and applies application settings automatically.

Infrastructure Monitoring Prometheus + Node Exporter

Collects server metrics such as CPU, memory, disk, and network usage.

Monitoring Dashboard Grafana

Displays Prometheus metrics through monitoring dashboards.

Migration Cloud MGN

Replicates the existing on-premises server to Cloud and supports the migration and cutover process.

Implementation Process

01
Assess the Existing Application
  • Use Nmap, Open-AudIT, and osquery to identify network services, server hardware, installed software, users, and running processes.
  • Analyze the Python application, PostgreSQL 14 database, dependencies, and customer data.
02
Provision the Cloud Infrastructure
  • Use OpenTofu to create the Cloud VPC, Cloud EC2, Cloud EBS, and Cloud S3 resources.
  • Configure the Cloud network and security settings.
  • Use Ansible to configure Ubuntu and install Python, PostgreSQL, and required dependencies.
03
Migrate the Application and Data
  • Use Cloud MGN to replicate the existing application server to Cloud.
  • Migrate the PostgreSQL 14 database and verify tenant, customer, subscription, invoice, and payment data.
  • Move customer files, invoices, and reports from local storage to Cloud S3.
04
Configure and Validate the Cloud Application
  • Configure Python, PostgreSQL, Systemd, Nginx, PAM, and UFW on the Cloud environment.
  • Verify that each tenant can securely access only its own billing data.
  • Test subscriptions, invoice generation, payments, reports, and file access.
05
Enable Monitoring and Go Live
  • Configure Prometheus + Node Exporter to collect infrastructure metrics.
  • Use Grafana to create monitoring dashboards.
  • Perform final application, database, security, and performance testing.
  • Redirect users to the Cloud application and monitor the environment after cutover.

Proposed Solution

The proposed solution replatforms the existing multi-tenant SaaS billing application from an on-premises server to Cloud. Cloud MGN migrates the existing application server to Cloud EC2, while OpenTofu provisions the Cloud infrastructure and Ansible configures the migrated environment. The main replatforming improvement is the storage layer. Customer files, invoices, PDFs, and reports are moved from local server storage to Cloud S3. The existing Python application, PostgreSQL database, and Ubuntu environment remain largely unchanged to minimize application modifications. Prometheus and Grafana provide monitoring of the Cloud environment. This approach reduces dependency on physical hardware, provides scalable file storage, and simplifies infrastructure management.

Benefits

Scalable file storage : Cloud S3 can store growing volumes of customer files.
Reduced hardware dependency : The application moves from a physical server to Cloud.
Minimal application changes : The existing Python application and PostgreSQL database are largely retained.
Automated deployment : OpenTofu and Ansible reduce manual infrastructure and server configuration.
Improved monitoring : Prometheus and Grafana provide visibility into infrastructure performance.
Tenant data separation : S3 and application-level controls can help ensure each tenant accesses only its own files.

Challenges

Tenant data security : Access to each tenant's files must be properly controlled.
Application modification : The application must be updated to use S3 instead of local file storage.
Data migration : Existing customer files must be transferred accurately to S3.
Cloud cost management : EC2, S3, and data-transfer costs need to be monitored.
Migration downtime : Final synchronization and application cutover must be carefully planned to minimize service interruption.