Ml Model Consume on Linode migrated from Azure Functions - Sandy Inspires
Tags: linodehackathon, python, writing
Published: 2023-02-19 16:23:47

## What I built ⚙

A Flask Web application running on `Linode's Shared CPU` where a binary classifier machine learning model file is placed in `Linode's Object Storage`, which is consumed by a `Flask` web application written in `Python` to do prediction, log the prediction status in `Linode's MySQL server`, and return results.

A complete and successful migration done from Azure Functions with Blob Storage to Linode's Shared CPU with Object Storage.

log_source, model_version, average response time (in seconds)
azure, v1, 0.030180000141263007
linode, v1, 0.021626923161630448

`Note: Lesser time is better`

### Category Submission 🧩
**Smooth Shifters** and Integration Innovators

### App Link ⛓
[Flask Web App Link](http://194.195.115.181/)

### Architecture Diagram 🧱

![Arcitecture Diagram](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ei0h25u977asj0iver3k.png)

### YouTube Video 🎬
{% embed https://youtu.be/9g36_NK3kNY %}

### Screenshots 🖼

#### MySQL server on Linode
![MySQL server on Linode](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7tpgoatn631unybl3ssl.png)

### Flask Server Usage Stats
![Flask Server Usage Stats](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9nk7mzwi7qcl6xt1b3tj.png)

### Flask Server Application Logs
![Flask App logs](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zwffizxuizolzg3j9ug3.png)

### Postman testing
![Postman request](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eu0vcz0oafvo2kdmx4vh.png)

### VS Code Folder Structure
![VS Code Folder Structure](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m2ydjgbrz2fv62ivq1zg.png)

### Average Response time comparison Linode Vs Azure

![MySQL database response time measure](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5rkf1rfj656paz0cysvo.png)

### Linode Services and Tools used 🛠

1) Flask (One-Click deploymentfrom marketplace) - Shared CPU - Naonde 1GB RAM - 1 CPU Core - 25 GB SSD
2) MySQL V8 - Shared CPU - Naonde 1GB RAM - 1 CPU Core - 25 GB SSD
3) Object Storage - for storing Machine learning models
4) Python
5) Flask - light-weight web framework
6) MySQL Workbench - connect to the remote database
7) Postman - testing out model endpoints

### Link to Source Code 👩‍💻
{% embed https://github.com/Santhoshkumard11/ml-model-consume %}

### Permissive License 🤓
**MIT**


## Background 🤠
I wanted to explore more on multi-cloud and how to integrate it with existing services or make services from different cloud providers to make things work seamlessly. This Linode hackathon give me the exact experience I was looking for, to integrate or migrate existing services in Azure to Linode to check compatibility between various services. 

To be honest, I learnt a ton of information about hosting a server and how to get apps running, yay, I did spend a lot of time in debugging stuff to see where things fail, Python version difference, OS dependencies, Python Package dependencies, setting up the virtual environment in the right place.


### Learnings from this Project 👨‍🎓
Deploying an actual server and getting it up and running was so cool. You don't get to do that with Azure, you just push the code and it just runs. Everything is under the hood. You miss out on all the interesting parts of deployment. Great knowledge on how a server works and how we can deploy services inside a server with supervisor and use Nginx to as both HTTP/HTTPS server. `Without Linode I don't believe I would've known how a server works and how the request is getting routed to a web application and to our Python code.`

Networking part is another interesting area that I explored, I didn't notice much when it was in Azure, as you get a HTTPS endpoint to hit and that all you know. Now you've an IP and you need domain name to be mapped to that IP to hit the endpoint with the domain name instead of IP address.

I'll definitely explore more on firewall rules and load balancer 
to see how these are configured and used in an actual server.


### Conclusion ✨
It was a super fun hackathon, enjoyed using Linode, super simple and clean UI. Love the shared instance starts with just $5 a month.

Would be deploying more applications in Linode for my future hackathons.

One hell of a hackathon it was! 

Special thanks to Linode and Dev team for hosting this hackathon.

Happy Learning! 📑
PRs are welcomed and drop your suggestions in the comments.

{% embed https://dev.to/sandy_codes_py %}

## Let's connect 🤝

#### [LinkedIn](https://linkedin.com/in/santhosh-kumard)

#### [Instagram](https://www.instagram.com/sandy_inspires)

#### [Twitter](https://twitter.com/sandy_inspires)