Ml Model Consume on Linode migrated from Azure Functions – Sandy Inspires

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…


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by Santhosh (sandy inspires)

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

Architecture Diagram 🧱

Arcitecture Diagram

YouTube Video 🎬

Screenshots 🖼

MySQL server on Linode

MySQL server on Linode

Flask Server Usage Stats

Flask Server Usage Stats

Flask Server Application Logs

Flask App logs

Postman testing

Postman request

VS Code Folder Structure

VS Code Folder Structure

Average Response time comparison Linode Vs Azure

MySQL database response time measure

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 👩‍💻

GitHub logo Santhoshkumard11 / ml-model-consume

Flask served ML model in Linode Shared Instance with files from Lindos Object Storage

Linode + DEV Hackathon 2023 - ML Model Consume - Sandy Inspires

This repo contains code that runs on Shared Linode Instance where multiple classifier model files are placed in Linode 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

Download the Postman collection which has sample API endpoints and JSON request body

Request URL - http://194.195.115.181

NOTE: this is a http endpoint and doesn't have a domain name yet

YouTube Demo Video 📺📺

Click here to watch the demo

video

Setup environment variable

Please set the below variables

  • LINODE_OBJECT_STORAGE_ACCESS_KEY - Linode Object Storage Access Key
  • LINODE_OBJECT_STORAGE_SECRET_KEY - Linode Object Storage Secret Key
  • MYSQL_HOST - MySQL host name
  • MYSQL_USERNAME - MySQL username
  • MYSQL_PASSWORD - MySQL user password
  • LATEST_MODEL_VERSION - the latest version of the model (V1, V2, etc)

Architecture Diagram

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.

Let's connect 🤝

LinkedIn

Instagram

Twitter


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by Santhosh (sandy inspires)


Print Share Comment Cite Upload Translate Updates
APA

Santhosh (sandy inspires) | Sciencx (2023-02-19T16:23:47+00:00) Ml Model Consume on Linode migrated from Azure Functions – Sandy Inspires. Retrieved from https://www.scien.cx/2023/02/19/ml-model-consume-on-linode-migrated-from-azure-functions-sandy-inspires/

MLA
" » Ml Model Consume on Linode migrated from Azure Functions – Sandy Inspires." Santhosh (sandy inspires) | Sciencx - Sunday February 19, 2023, https://www.scien.cx/2023/02/19/ml-model-consume-on-linode-migrated-from-azure-functions-sandy-inspires/
HARVARD
Santhosh (sandy inspires) | Sciencx Sunday February 19, 2023 » Ml Model Consume on Linode migrated from Azure Functions – Sandy Inspires., viewed ,<https://www.scien.cx/2023/02/19/ml-model-consume-on-linode-migrated-from-azure-functions-sandy-inspires/>
VANCOUVER
Santhosh (sandy inspires) | Sciencx - » Ml Model Consume on Linode migrated from Azure Functions – Sandy Inspires. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2023/02/19/ml-model-consume-on-linode-migrated-from-azure-functions-sandy-inspires/
CHICAGO
" » Ml Model Consume on Linode migrated from Azure Functions – Sandy Inspires." Santhosh (sandy inspires) | Sciencx - Accessed . https://www.scien.cx/2023/02/19/ml-model-consume-on-linode-migrated-from-azure-functions-sandy-inspires/
IEEE
" » Ml Model Consume on Linode migrated from Azure Functions – Sandy Inspires." Santhosh (sandy inspires) | Sciencx [Online]. Available: https://www.scien.cx/2023/02/19/ml-model-consume-on-linode-migrated-from-azure-functions-sandy-inspires/. [Accessed: ]
rf:citation
» Ml Model Consume on Linode migrated from Azure Functions – Sandy Inspires | Santhosh (sandy inspires) | Sciencx | https://www.scien.cx/2023/02/19/ml-model-consume-on-linode-migrated-from-azure-functions-sandy-inspires/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.