Skip to content
Branch: master
Find file History
parano Deployment CLI help docs and option shortcuts (#312)
* Update

* update examples/guides

* Update

* Update

* fix linter error
Latest commit 4b5a8b7 Sep 26, 2019

Deploy BentoML service as serverless function on AWS Lambda or Google Cloud Function


Cloud providers offer serverless computing service to help teams deploy a scalable services without worry about hardware configuration and maintains. This benefit may also apply to machine learning as well.

In this example, we will train a sentiment analysis model with SciKit-learn, and then use BentoML to create serverless archive and deploy to AWS lambda service with the Serverless framework.

We will exame the benefits and challenges of deploying machine learning services to serverless services. And then, we will use BentoML to deploy the trained model to AWS Lambda with one command, and take a closer look of the entire process.

Developing sentiment analysis model

We will train a scikit-learn model, and then we will use BentoML to package it. You can follow those steps in the Jupyter Notebook

Prerequisites for deploying model to AWS Lambda

  • Install Node.JS. Follow the instructions on
  • Install Serverless framework. You can find instructions here
  • AWS account configured on your machine
    1. Install AWS CLI. Instructions
    2. Configuring with your AWS account. Instructions

Deploy to AWS lambda

It is simple to deploy to AWS Lambda with BentoML. After you saved your model as BentoML bundle, you invoke a single command.

bentoml deployment create my-serverless-deployment --bento BENTO_NAME:BENTO_VERSION --platform aws-lambda --region us-west-2

What happens after the deploy command

BentoML does serveal things under the hood that help data scientists to deploy their model services to AWS lambda.

BentoML will invoke AWS to create different services. Those services managed by CloudFormation. When the process complete, you will see the Lambda function in service.


Finally, you will see the Lambda function show up on your AWS Dashboard. ScreenShot

To make a prediction request, you can use CURL command. Copy and paste the following command and update data and url base on your deployment

curl -i \
--header "Content-Type: application/json" \
--request POST \
--data '["good movie", "bad food"]' \


Check deployment status

bentoml deployment describe my-serverless-deployment

Delete deployment from AWS lambda

Delete deployment from AWS lambda is as simple as deploy it. To delete deployment use bentoml delete-deployment command.

bentoml deployment delete my-serverless-deployment
You can’t perform that action at this time.