Quantcast
Channel: Machine Learning | Towards AI
Viewing all articles
Browse latest Browse all 792

Deploy MLflow Server on Amazon EC2 Instance

$
0
0
Author(s): ronilpatil Originally published on Towards AI. Image by Author Hi folks! Ready to take your model deployment game to the next level? Let’s dive into setting up an MLflow Server on an EC2 instance! I’ll explain the steps to configure Amazon S3 bucket to store the artifacts, Amazon RDS (Postgres & Mysql) to store metadata, and EC2 instance to host the mlflow server. So let’s begin! Table Of Content — Introduction — Create S3 Bucket — Create EC2 Instance (Ubuntu) — Configure PostgreSQL DB — VPS & Security Groups — Configure MySQL DB — Access MLflow Server Remotely — GitHub Repo — Conclusion Introduction In this blog, we’ll delve into the nuts and bolts of deploying an MLflow server on an Amazon EC2 instance, empowering you to harness the full potential of your machine-learning projects on the cloud. By hosting MLflow on Amazon EC2 with an S3 bucket and RDS instance as the backend, we leverage the scalability and flexibility of cloud computing, ensuring seamless access to our experiments and models from anywhere in the world.This guide will walk you through the step-by-step process of setting up our own MLflow server on Amazon EC2, S3 Bucket & RDS instance as a backend store. Get ready to supercharge your machine-learning projects and unlock new levels of productivity. Let’s dive in! Create S3 Bucket In my previous blog, I explained the way to create S3 Bucket. You can refer to it. Configure DVC with Amazon S3 Bucket A step-by-step guide to configure DVC with Amazon S3 Bucket pub.towardsai.net Create EC2 Instance (Ubuntu) Step 1. Search for EC2, go to instances (left panel), and click on Launch an instance. Give any name to instance & move down. Image by Author Step 2. For sure ubuntuU+1F5A4, select it & move down. Image by Author Step 3. Click on Create new key pair, a new panel will pop up. Image by Author Step 4. Enter the key pair name and click on Create key pair. Image by Author Step 5. Look, by default it will create a new security group. Now we’ll proceed with a new security group but we can also use the existing one. Mark all checkboxes and click on Launch instance. Image by Author Step 6. CongratsU+1F389 EC2 instance created successfully. Just go to your instance and click on Connect. Image by Author Step 7. Again click on Connect, and keep the remaining options as default. Image by Author Step 8. You’ll see a command line interface. That’s it!!! Image by Author Note: Our EC2 instance is ready, now first we need to set an inbound rule for the EC2 instance for port 5000. What!!! & Why?Look, When we send data to your MLflow server, such as experiment metrics or parameters, we do so by making HTTP requests to specific API endpoints provided by MLflow. By default MLflow server uses port 5000, so by configuring the inbound rule for port 5000, we’re allowing these HTTP requests to reach our MLflow server running on our EC2 instance. Now external systems or users can send these HTTP requests to our EC2 instance’s public IP address on port 5000, effectively interacting with our MLflow server and enabling functionalities such as experiment logging, metric tracking, and project management. For more details check out VPS & Security Groups section. Step 9. Go to Instances, and click on the instance ID. Image by Author Step 10. Go to Security panel, and click on security group. Image by Author Step 11. Click on Edit inbound rules. Image by Author Step 12. Click on Add rule, select Type as Custom TCP, Port as 5000, and Source as 0.0.0.0/0 (incoming traffic from any IP address is allowed), and then save the rules. That’s it. Image by Author Configure PostgreSQL Database Step 1. Search for RDS Services, click on Create database, and select Standard create & move down. Image by Author Step 2. Select PostgreSQL and move down. Image by Author Step 3. Select Free tier and move down. Image by Author Step 4. Give any name to DB instance and Master username and move down. Keep it safe, we will need it further. Image by Author Step 5. Give any password and move down. Image by Author Step 6. You’ll see Additional configuration panel, expand it and enter the database name, move down, and click on Create database. Image by Author CongratsU+1F389, PostgreSQL DB created successfully. Look, our MLflow server is running on an EC2 instance and it's using PostgreSQL as backend storage right? But how EC2 will communicate with this database? Let me explain it separately. VPS & Security Groups AWS organizes resources into virtual networks called Virtual Private Clouds (VPCs). Think of a VPC as a private space in the AWS cloud where we can place our resources, like EC2 instances, RDS, ECS (Elastic Container Service), EKS (Elastic Kubernetes Service), Redshift (Fully managed data warehouse service), and many more. This resource uses network configuration to communicate with others. Now we need something that can make this communication controlled & secure. Here Security Groups come into the picture. Security groups are like virtual firewalls that control the flow of network traffic to and from these resources within a VPC. They help us to manage who can access our resources and what kind of traffic is allowed. Inbound Traffic — The traffic coming into the resources.Outbound Traffic — The traffic going out from the resources. We’ve an EC2 instance where we’ve hosted an MLflow server. We also have a PostgreSQL RDS instance, which serves as a backend store where MLflow stores its metadata. This includes information about experiments, parameters, metrics, and more. By configuring the inbound rule in the security group associated with our PostgreSQL RDS instance we’re allowing incoming connections from your EC2 instance (where the MLflow server is hosted) to access the PostgreSQL database using port 3306. In summary, by configuring the inbound rule to allow traffic on port 3306 from your EC2 instance to our PostgreSQL […]

Viewing all articles
Browse latest Browse all 792

Trending Articles