Carrot-Mapper Agnostic Solutions #53
CodeByKarthik
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Background & Problem Statement
🔺➤ Why are we using Azure in Carrot Mapper?
We are using Azure Services for 3 main reasons which are mentioned below:
🔺➤ Role of Azure Services in Carrot Mapper?
Azure Functions serve as a serverless computing platform that enables event-driven execution of tasks in Carrot Mapper. They are used for:
We are using Azure Functions to automatically process, modify, and store mapping rules in Azure Blob Storage whenever a new request or event is triggered.
When a user requests a mapping rules export, an Azure Function is triggered and the function fetches the mapping rules from the database automatically.
It then generates a JSON, CSV, or SVG file and the function uploads the generated file to Azure Blob Storage for download.
Azure Functions automate background data processing tasks like Transforming scan report data, Extracting mapping rules from datasets and rules generation.
Summary
- - - - - - -
🔺➤ Problem Statement - Carrot Mapper is a Native Azure Application !
Currently, Carrot Mapper is not cloud-agnostic because it is locked into Azure services.
Now, we need Carrot Mapper to be deployed as a Cloud-Agnostic than a Native Application.
🔺➤ Why is this a Problem Statement?
The issue is that Carrot Mapper is not cloud-agnostic as it is locked into Azure.
What could be the potential Blockers?
Since Carrot Mapper’s core logic relies on the Azure Ecosystem, it is challenging to shift from Native Driven Application to Cloud Agnostic Solution.
Any Solutions?
Yes, there are multiple solutions which are briefly discussed below.
Approach 1 - Serverless Frameworks instead of Azure Functions
Use Serverless Frameworks to replace Azure Functions and make Carrot Mapper cloud-agnostic so that it can work on Azure, AWS, GCP, or even on-premise environments.
The azure Functions can be removed and replaced with Serverless Framework for event-driven execution of tasks in Carrot Mapper.
https://www.serverless.com/
There are other optios for function as a service
But there is a problem!
- - - - - - - - - - - - - - - -
Even if we remove Azure functions, we need to solve the storage problem separately.
Use MinIO (Agnostic Storage) instead of Blob Storage
MinIO is an S3-compatible storage solution (MinIO’s S3-compatible SDK) instead of Azure Blob Storage (Azure Blob Storage SDK).
https://min.io/
Other Multi-Cloud Storage Services
🔺➤ Will it entirely solve the issue ?
While using Serverless Framework and MinIO (or other S3-compatible storage) almost solves the cloud-agnostic issue, there are still a few things that need to be considered:
🔺➤ What would be the solution?
Write infrastructure as a code for kubernetes set up
{ optional } Use Terraform for writing the infrastructure code.
Approach 2 - Remove Azure Functions & Convert to a Python Package with Cloud Provider Endpoints
To achieve cloud-agnostic deployment, we remove Azure Functions and convert its logic into a standalone Python package.
This package will be responsible for executing Carrot Mapper’s core functionalities while integrating with different cloud providers dynamically.
Step 1:
__init__.py) logic into a separate Python package.Step 2:
Reorganize the logic into a Python package that can be installed and used in different environments.
Step 3:
Setting up the storage for triggers and uploads.
Use different storage solutions depending on the selected cloud provider (AWS S3, GCP Cloud Storage, Azure Blob Storage).
Implement MinIO or Cloudflare R2, which are S3-compatible and work across all cloud providers.
{ Recommended Approach }
- - - - - - - - - - - - - - - - - - - -
Using MinIO or other fully cloud-agnostic storage while keeping the option open for cloud-native storage services.
Setp 4:
Setting up deployment
Create separate Docker configurations for Azure, AWS, and GCP and each cloud provider will have its own optimized Docker image.
Use Kubernetes (K8s) to deploy the application across different cloud environments. It allows for multi-cloud deployments without cloud-specific configurations.
🔺➤ How it works?
The Python package will contain the core logic, but we still use cloud-specific serverless functions only to trigger the package.
The Python package will contain the core logic and Django API will be used for triggers and executes functions.
In this approach, the Python package will encapsulate the core business logic, making it independent of any cloud provider.
However, we will still use cloud-specific serverless functions (such as AWS Lambda, GCP Cloud Functions, or Azure Functions) only for triggering the package.
Additionally, the Django API will act as a centralized event handler, responsible for managing triggers, executing functions dynamically, and handling cloud-specific interactions.
This eliminates the need for hard-coded cloud dependencies inside the package while maintaining flexibility for deployment across different cloud environments.
Approach 3 - Routing Wrapper Model
This approach introduces a Routing Wrapper Model that determines which cloud provider (Azure, AWS, GCP, or Local) is being used and dynamically configures the system accordingly.
By performing this, Carrot Mapper can work across multiple cloud providers without requiring major code changes.
🔺➤ How it works?
Instead of directly calling Azure Functions and Blob Storage, we introduce a placeholder routing model that selects the correct cloud provider at runtime.
This is controlled via environment flags or configuration files.
Replace the Azure Functions and Blob Storage into the Routing Model placeholder. We can use flags to control what cloud provider which we want to use and based on the cloud provider, the configurations will be set up and imports will be executed.
This ensures the system can work with Azure, AWS, GCP, or even locally without major code changes.
When configuring the routing model, there are two approaches
We use a simple condition to determine the cloud provider and execute the relevant logic.
Example Psudocode: Conditional Routing for Function Execution
Instead of hardcoding cloud-specific logic, we define a configuration file (YAML/JSON) where the user can set the cloud provider.
Example Psuedocode: Configuration for Cloud-Agnostic Setup
Then, load the config dynamically as follows:
Steps for implementation
Step 1 :
Locate the Azure Functions that are responsible for:
These functions need to be abstracted into a routing model.
Step 2:
We introduce a Cloud Function Wrapper that routes the correct cloud provider function dynamically.
Example Pseudocode: Cloud Function Handler
Step 3:
Implement Cloud-Specific Methods
Instead of calling Azure functions directly, all cloud function calls will go thorugh CloudFunctionRouter which makes carrot cloud-agnostic.
Step 4:
Currently, Carrot Mapper uses Azure Blob Storage to store exported mapping rules and files. Instead, we replace it with a unified storage interface that can use AWS S3, GCP Storage, Azure Blob, or local storage.
Example Pseudocode: Cloud Storage Handler
Final step:
Now that we removed Azure Functions & Blob Storage, we can deploy Carrot on any cloud!
docker-compose.ymlto support different clouds.Optional:
Configure the deployement process and add it in the logic so that the user will only needs to run the flag of the cloud provider and everything will be executed automatically.
🔺➤ Advantages of this approach
By using conditional logic + dynamic imports + a separate parsing model, you are essentially decoupling cloud-specific logic from the core application. This optimizes performance because:
Other Hybrid Approaches
💡Approach 1: Cloud Routing Technique for a Python Package
💡Approach 2: Hybrid Approach (Combining Python Package + Routing)
💡Approach 3: Python Package + Agnostic Storage + Deployment Setup using Flags
This approach builds upon Approach 2 but adds support for storage independence and automated deployment configuration using flags.
💡Approach 4: Python Package + Agnostic Storage + Kubernetes Configuration
This approach expands Approach 3 by introducing Kubernetes as a deployment solution.
🔺➤ Deployment Complexity ?
Approach 3 and 4 will be preferred methodologies 12 Factor App Principles and our use case.
🔺➤ Cloud Portability and Latency?
💡Approach 3 (Python package & Deployment Routing + Agnostic Storage + Flags)
Best for minimal complexity and flexibility across cloud providers.
Fast and easy deployment using flags.
Good balance between maintainability and automation.
{Optional} - Use Serverless Functions instead of relying on Django Core functionalities for Triggers and Actions.
💡Approach 4 (Python package + Agnostic Storage + Kubernetes)
Best for large-scale, enterprise-grade deployments.
Highly scalable and fully automated but more complex setup.
Ideal for multi-cloud and hybrid cloud environments.
{Optional} - Use Serverless Functions instead of relying on Django Core functionalities for Triggers and Actions.
Preferred Methodology
For the Carrot-Agnostic Solution Discussions in PDF, I have attached and please find it below:
Carrot-Mapper-Agnostics-solution.pdf
All reactions