Process for Upload/deploy Python App on Aws Elastic Beanstalk Through Console
Paradigm i- https://static7.depositphotos.com/1020804/754/i/600/depositphotos_7541455-stock-photo-green-beans.jpg
learning model development comprising of data cleaning, wrangling, comparing different ML models, training the models on Python Notebooks similar Jupyter. All the higher up steps are of form undoable without the presence of such notebooks. However, these notebooks are limited for use past the developers as they cannot exist directly utilized for an application past whatever not-technical user.
Moving from Notebooks to Products
If y'all use any website for checking the weather condition forecasts of your metropolis, the forecasts that y'all see are coming from a model that might have got developed in some notebook simply the users are using the website for the forecasts.
As y'all must have guessed, there are therefore ways to catechumen the notebooks to a class that can be integrated into a production that can be accessed and utilized by any person – technical or non-technical users. This process is called 'model deployment'.
What's in this Article for Yous?
- ✔️ Get a basic understanding of AWS ElasticBeanstalk – what it does, when should you use it
- ✔️ Get to know how to build a basic Flask App
- ✔️ Acquire stepwise how to deploy the app on AWS ElasticBeanstalk
- ✔️ Understand when you should employ AWS ElasticBeanstalk for deployment over other AWS services
Icebreaking with AWS Elastic Beanstalk:
AWS Elastic Beanstalk is a compute service that allows you to upload code of your web application along with environment configurations – based on which Elastic Beanstalk automatically provisions and deploys the necessary resources required inside AWS to make the spider web app operational. These resources tin include other AWS services and features like EC2 instances, elastic load balancing, autoscaling, etc.
Equally a information science professional, if you lot are not familiar with the nitty-gritty of model deployment, information technology would be ideal for yous to use AWS Elastic Beanstalk to deploy your ML model as information technology automates and simplifies the whole process of deployment.
How much does information technology toll to utilise AWS Elastic Beanstalk?
AWS Elastic Beanstalk as a service is free to use. However, the resources that are utilized to create the application similar EC2 instances come at a charge equally per the standard pricing policy at the time of deployment.
Benefits of AWS Elastic Beanstalk
- ⭐ AWS EBS offers aelementary and quick fashion to deploy web applications.
- ⭐ With EBS, yous can focus on your application code rather than provisioning and configuring AWS resources.
- ⭐ Motorcar-scaling settings on EBS helps automatically scale the application.
- ⭐ Ane has control over all the AWS resource like EC2 that are powering the app.
- ⭐ AWS EBSprovides a cost-effective price in which one has to pay for what one uses and there are no hidden costs.
- ⭐ AWS EBS supports Java, .Cyberspace, PHP, Node.js, Python, Scarlet, Go, and Docker web applications.
- ⭐ Access to monitoring metrics like CPU utilization, request count, and latency.
Steps to Follow for Deployment👣
Things you demand:
- ☝ AWS account
- ☝ Knowledge of Python (Jupyter Notebooks)
✍ Building a Flask API
Flask is a web framework that tin be used to build web apps with Python.
We can install 'Flask' using the following line of code :
pip install flask
Mail installing, you could import the library and then create an application object. We add a route ("/") to display the 'Hello Earth! ' message. A route enables mapping a web URL to a Python function. Whatsoever the role returns is shown to the user on the web URL.
from flask import Flask awarding = Flask(__name__) @app.route("/") def hello(): return "How-do-you-do World!" if __name__ == "__main__": app.run()
Write the above lines of lawmaking in a .py file and name it as 'application.py'.
✍ Creating a Requirements.txt file
We will need a requirements.txt file that lists all the libraries that we take used in our 'application.py' file. For our case, this consists of only the following line:
Flask==1.0.two
After nosotros have created this file, we can zip these two files that tin be afterwards used while creating the application.
✍ Creating an application on AWS Elastic Beanstalk
Sign in to AWS Console and search for AWS ElasticBeanstalk. Click on 'Create Awarding. We can give our application a name. For the platform, we choose Python iii.8 and for the application code, we upload the .zero file that we created before.
✍ Creating an Surroundings
Once nosotros have uploaded the source code of our application, we can see the environment of our application getting created and finally the application getting created with a web URL assigned to the awarding.
What else do you go?
- 👉 Dashboard for checking the wellness condition of your app and recent events.
- 👉 Configuration board using which you can manage the entire environment.
- 👉 Logs – the logs from your app that enables tracking what went wrong in case your deployment fails
- 👉 Monitoring lath – for checking some basic metrics similar CPU utilization and network traffic.
- 👉 Alarms based on monitoring metrics – Warning email could be set up which y'all can receive when for instance CPU is utilized over lxxx% for a specific menses of fourth dimension.
When to deploy AWS Elastic Beanstalk over EC2?
EC2 is Amazon's service that tin exist utilized for creating a server (or instances) in the AWS cloud. On the other hand, Rubberband Beanstalk is i layer of abstraction away from the EC2 layer. Elastic Beanstalk sets up an "environment" for us that tin contain multiple EC2 instances, an optional database, every bit well as a few other AWS components such as elastic load balancing, autoscaling, etc. Rubberband Beanstalk manages these items for us whenever nosotros want to update our application.
If yous are trying to deploy a simple app in a short period of fourth dimension(similar an app that just displays a list of things), you can go for Elastic Beanstalk.
⚠️⚠️ Still, there are some situations when you would similar to prefer EC2 over AWS Elastic Beanstalk. If y'all accept developed an app that has a lot of things going around in information technology like multiple file uploads, simultaneous calculations, continuous delivery of notifications to users, etc., information technology would exist a better option to leverage EC2 .
About Author
Nibedita Dutta
Nibedita completed her master's in Chemical Engineering from IIT Kharagpur in 2014 and is currently working as a Senior Consultant in an analytics firm. In her current capacity, she works on building AI/ML-based solutions for clients from an array of industries.
Image Sources:
1.https://static7.depositphotos.com/1020804/754/i/600/depositphotos_7541455-stock-photo-green-beans.jpg
two.https://data.solita.fi/wp-content/uploads/2020/05/anniina_kuva01artboard-2-1.png
three.https://blog.eventzilla.internet/event-resources/ten-icebreaker-ideas-for-networking-events/
4.https://world wide web.kindpng.com/imgv/hRxxTh_qlik-dashboard-icon-hd-png-download/
The media shown in this commodity is not owned by Analytics Vidhya and are used at the Author's discretion.
Source: https://www.analyticsvidhya.com/blog/2021/11/deploying-a-flask-app-on-aws-elastic-beanstalk/