Transforming the MyPetParlor App API to a global and scalable API
Luthando A. Vilakazi
In a strategic move to transform its API architecture, the MyPetParlor App team has successfully implemented a stamp-based design that enhances multi-tenant support, improves scalability, and enables regional deployments. This new multi-tenant and multi-stamp API not only optimises Firebase resource management but also establishes a unified platform that will drive both the current MyPetParlor App product and future offerings, including e-commerce solutions, to support our growing customer base's evolving needs.
Following our successful Azure infrastructure migration completed in March 2024, which implemented the Deployment Stamps pattern for improved scalability and multi-tenant support, we've now extended this architectural approach to our API layer and Google Cloud infrastructure. This transformation enables us to support multiple tenants and their applications while maintaining optimal resource utilisation and preparing for global expansion.
A key driver for this transformation was the inherent limitations of Firebase resources within a single Google Cloud project. Our production environment was approaching critical limits with:
A maximum of 30 Firebase Apps registered per project (we require 3 per tenant for Android, iOS, and web)
A single Firebase Hosting service per project
A single Firebase App Check service per project
A single Firebase Cloud Firestore service per project
A single Firebase Authentication service per project
A single Firebase Analytics (powered by Google Analytics) service per project
A single Firebase Crashlytics service per project
A single Firebase Performance Monitoring service per project
A single Firebase Cloud Messaging service per project
Additionally, the 8 Firebase services that our tenants' Android, iOS, and web apps depended on to function could only be accessed by apps registered to the project. Once we reached 10 tenants, we needed a way to handle additional tenants and employ a solution that would allow us to scale beyond these constraints while maintaining the benefits of Firebase's ecosystem.
Rather than migrating to alternative third-party services, we implemented a stamp-based approach similar to our Azure infrastructure. This innovative solution:
Creates multiple Google Cloud projects (stamps)
Allocates 10 tenants per stamp
Enables each tenant within a stamp to deploy:
1 Android application
1 iOS application
1 Web application (future-proofing)
This approach effectively multiplies our capacity by distributing tenants across multiple stamps while staying well within Firebase's project limits.
To support this new architecture, we've implemented new API headers that enable intelligent routing and configuration:
X-MBA-Application-ID
: Identifies the specific application making the request
X-MBA-Application-Type
: Specifies the type of application (e.g., MyPetParlor App, E-commerce platform)
X-MBA-Deployment-Location
: Determines the geographical deployment stamp (e.g., za, us, uk)
The transformed API now features a sophisticated routing system:
API Gateway Layer:
Uses the deployment location header to route requests to the correct regional stamp
Ensures optimal latency by directing traffic to the nearest deployment
Application Configuration:
Stores application-specific configurations in a centralised database
Maps application IDs to their corresponding Google Cloud resources
Maintains separate configurations for different applications
Resource Resolution:
Dynamically resolves Firebase and Google Cloud resource endpoints
Ensures requests are routed to the correct stamp's resources
Maintains isolation between tenants while enabling resource sharing
This transformation positions us to launch our e-commerce platform, which can be:
Deployed as a standalone product
Integrated as an add-on to existing MyPetParlor App installations
Scaled independently across different regions
The multi-tenant, multi-stamp architecture ensures that we can maintain separate configurations and resources for different applications while leveraging shared infrastructure where appropriate.
The transformed API brings several key advantages:
Scalability: Effectively bypasses Firebase project limitations through stamp-based architecture
Regional Performance: Optimised request routing based on geographical location
Application Agnostic: Single API supporting multiple products and applications
Resource Optimisation: Efficient utilisation of Google Cloud and Firebase resources
Future-Ready: Prepared for additional products and regional expansions
With this API transformation complete, we're well-positioned to:
Launch our e-commerce platform
Expand into new geographical regions
Develop and deploy additional products
Scale our tenant base efficiently
The new multi-tenant, multi-stamp API architecture represents a significant milestone in our platform's evolution, enabling us to serve more customers, support more products, and expand into new markets while maintaining optimal performance and resource utilisation.
Company
Blog →MyPetParlor App is the global pet care platform for mobile groomers and parlor groomers.
© 2024 MyBusiness App (Pty) Ltd. All rights reserved.