Published in


Deployment of a Machine Learning model into Amazon EC2(Part 2- Real-Time Deployment)

by Pronay Ghosh and Hiren Rupchandani

  • In the previous article, we saw how to how to set up our server into Amazon EC2.
  • We understood the setup of a Linux box.
  • Now is the time to deploy a machine learning model into Amazon EC2.
  • Hence, in this article, we will deploy a trained machine learning model into Amazon EC2.
  • In order to do so, we will have to go through the following steps

Creating a Security Group:

  • Now, we will have to set up the EC2 instance accessible from anywhere.
  • In order to do so, go to the EC2 instance and select the security group.
  • Click on Inbound and then click on add rule.
  • Set the type of the rule to All traffic.
  • In source Give permission for anywhere.
  • Basically one can use it from anywhere with IPv4 and IPv6 network protocols.

Setting up the Network Interfaces:

  • After setting up the security groups one should go to the network interfaces section.
  • After that right-click on the interface and select change security groups.

Setting up the system dependencies:

  • Now, we need to go back to the terminal and install the system dependencies in order to deploy our model.
  • For that, we need to use the following command
pip3 install -r requirements.txt
  • After running the command we can see that the system dependencies have been successfully installed.
  • After that, in the terminal use the following command
  • We can now see that, the app is running with port number 5000

Deploy into EC2:

  • As the final step, we will have to go back to the EC2 instances in the AWS management console.
  • From the instances, we will have to select the EC2 instance.
  • After that, we will have to click on actions and click on connect.
  • After that, we can see our URL.
  • We will simply have to add the port number.
  • Here, the port number is 5000 hence, we have added <The EC2 URL>/5000
  • Open this entire link in a new tab and you can see your model live on Amazon Elastic Compute Cloud (EC2).


  • In this article, we covered a high-level overview of how to deploy a machine learning model into Amazon EC2.
  • In the next article, we will see how a high-level overview of Amazon S3.
  • We will also understand how to run a jupyter notebook into the cloud using Amazon Sagemaker.

Final Thoughts and Closing Comments

There are some vital points many people fail to understand while they pursue their Data Science or AI journey. If you are one of them and looking for a way to counterbalance these cons, check out the certification programs provided by INSAID on their website. If you liked this story, I recommend you to go with the Global Certificate in Data Science & AI because this one will cover your foundations, machine learning algorithms, and deep neural networks (basic to advance).

Follow us for more upcoming future articles related to Data Science, Machine Learning, and Artificial Intelligence.

Also, Do give us a Clap👏 if you find this article useful as your encouragement catalyzes inspiration for and helps to create more cool stuff like this.




INSAID is India’s leading powerhouse in Data Science & AI research and education. INSAID provides world-class programs and certifications to working professionals across 300+ companies

Recommended from Medium

Writing a basic REST API with Flask and Flask Restful (A flask extension) in Python

Golang In Blockchain

The ultimate list of Web Scraping tools and software

Multimodal Language Acquisition Tool for People in the Autism Spectrum Disorder (ASD)

How to Get Started in Software Engineering (Free of Cost)

A person with code projected over their face and body

Subscribe To Salesforce Platform Events With Python

Einsum equation:

10 Cool Tips for Writing Robust Bash Scripts

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Pronay Ghosh

Pronay Ghosh

Data Scientist at Aidetic | Former Data Science researcher at The International School of AI and Data Science

More from Medium

Deployment of a Machine Learning model into Amazon EC2 (Part 1- Warm-up of EC2)

A Must Read Article for every ML Engineer/ Data Scientist if you want to deploy ML App on cloud in…

Deploy Machine Learning Model using Amazon SageMaker (Part 2)

Machine Learning on AWS SageMaker