All Products
Search
Document Center

Online model service example

Last Updated: Jun 01, 2020

Create and deploy an online model service

This topic describes how to use Machine Learning Platform for AI to create and deploy a heart disease prediction service. The procedure includes model training and online service debugging.

  1. Log on to Alibaba Cloud Machine Learning Platform for AI.

  2. On the homepage of the console, use the heart disease prediction template to create an experiment and then click Run to run the experiment.

If all of the components in the experiment are labeled with a green check, then the system has successfully run the experiment.

(https://img.alicdn.com/tfs/TB1CsZOGb9YBuNjy0FgXXcxcXXa-232-75.png)

  1. Select Deploy > Online Model Service.

(http://docs-aliyun.cn-hangzhou.oss.aliyun-inc.com/assets/pic/92917/cn_zh/1544598032496/fig.png)

  1. Select the model that you want to deploy, and then click Next.

(http://docs-aliyun.cn-hangzhou.oss.aliyun-inc.com/assets/pic/92917/cn_zh/1544598092785/fig.png)

  1. Select a deployment mode. Alibaba Cloud Machine Learning Platform for AI supports the following deployment modes.
  • New Service
  • Add Existing Service Version
  • Create Blue-green Deployment

New service

  1. After you select the New Service deployment mode, enter a model name.

  2. Set the Processes and Quota parameters.

    Processes determine the number of programs that can run in parallel. We recommend that you set this parameter to a value greater than or equal to 2 to improve the stability of the model output. Quata determines the response time (RT), queries per second (QPS), and how fast the programs can run.

(http://docs-aliyun.cn-hangzhou.oss.aliyun-inc.com/assets/pic/92917/cn_zh/1544598714362/fig.png)

  1. Click Next, confirm the information, and then click Deploy.

    (http://docs-aliyun.cn-hangzhou.oss.aliyun-inc.com/assets/pic/92917/cn_zh/1544598682785/fig.png)

  2. After the model is deployed, click the model name to view the model invocation information.

(http://docs-aliyun.cn-hangzhou.oss.aliyun-inc.com/assets/pic/92917/cn_zh/1544599423403/fig.png)

  1. Click the icon in the Monitor column to view the monitoring data, including the QPS, Response, RT, Traffic, CPU, Memory, and Daily Invoke information.

(https://img.alicdn.com/tfs/TB1FmxjXjrguuRjy0FeXXXcbFXa-1661-858.png)

  1. If you need to scale out resources, click Update.

(http://docs-aliyun.cn-hangzhou.oss.aliyun-inc.com/assets/pic/92917/cn_zh/1544599575864/fig.png)

  1. If you want to perform online model debugging, click Online Debugging in the upper-right corner of the Online Model Service page.

(http://docs-aliyun.cn-hangzhou.oss.aliyun-inc.com/assets/pic/92917/cn_zh/1544599724419/fig.png)

Add existing service version

  1. After you set the deployment mode to Add Existing Service Version, select a deployed model from the drop-down list under Select Deployed Model Service.

(http://docs-aliyun.cn-hangzhou.oss.aliyun-inc.com/assets/pic/92917/cn_zh/1544600258088/fig.png)

  1. Click Next, confirm the information, and then click Deploy.

    Note: The Add Existing Service Version mode may take several minutes to deploy a model. Please wait.

  2. After the model is deployed, click the drop-down list in the Current Version column to switch the model version.

(http://docs-aliyun.cn-hangzhou.oss.aliyun-inc.com/assets/pic/92917/cn_zh/1544600564798/fig.png)

Create blue-green deployment

The new version of Alibaba Cloud Machine Learning Platform for AI supports the blue-green deployment. The blue-green deployment allows you to run two model versions at the same time. You can distribute a specified amount of network traffic to the new version for testing purposes. After you confirm that the new version is running normally, you can then switch all of the network traffic to the new version. The blue-green deployment helps you deploy a new mode version without service downtime and with the minimum risk.

  1. After you set the deployment mode to Create Blue-green Deployment, select a deployed model from the drop-down list under Select Deployed Model Service, and then set the parameters under Resources for Model Deployment. By default, the model in use is selected.

    (http://docs-aliyun.cn-hangzhou.oss.aliyun-inc.com/assets/pic/92917/cn_zh/1544600838284/fig.png)

  2. Click Next, confirm the information, and then click Deploy.

  3. Click Distribute Traffic in the Actions column, and then specify the proportion of network traffic distributed to the former version and new version. By default, 100% is set for both versions.

(http://docs-aliyun.cn-hangzhou.oss.aliyun-inc.com/assets/pic/92917/cn_zh/1544601011129/fig.png)

Online debugging and API Gateway features

Online debugging

  1. Click Online Debugging in the upper-right corner of the Online Model Service page, select the current model, and then click Run to perform online debugging.

(http://docs-aliyun.cn-hangzhou.oss.aliyun-inc.com/assets/pic/92917/cn_zh/1544601462332/fig.png)

  1. On the API debugging page, complete the identity and authorization verification.

Click +Add under Headers, and then enter Authorization and the relevant information.

(http://docs-aliyun.cn-hangzhou.oss.aliyun-inc.com/assets/pic/92917/cn_zh/1544601681651/fig.png)

To obtain the Authorization information, click the model name. The information is shown under Key.

(http://docs-aliyun.cn-hangzhou.oss.aliyun-inc.com/assets/pic/92917/cn_zh/1544601891393/fig.png)

  1. Enter the input data (input features) into the Body field. Taking the logic regression model used for heart disease prediction as an example, enter the following information:
  1. [{"sex":0,"cp":0,"fbs":0,"restecg":0,"exang":0,"slop":0,"thal":0,"age":0,"trestbps":0,"chol":0,"thalach":0,"oldpeak":0,"ca":0}]

(http://docs-aliyun.cn-hangzhou.oss.aliyun-inc.com/assets/pic/92917/cn_zh/1544602017043/fig.png)

  1. Click Send Request to get the prediction result.

(http://docs-aliyun.cn-hangzhou.oss.aliyun-inc.com/assets/pic/92917/cn_zh/1544602203048/fig.png)