×
Community Blog Function Compute Tutorials that You'll Not Want to Miss - Part 1

Function Compute Tutorials that You'll Not Want to Miss - Part 1

Read this article to learn about what you can do with Alibaba Cloud Function Compute.

Alibaba Cloud Function Compute is a fully hosted and serverless running environment that takes away the need to manage infrastructure and enables businesses to focus on software development. You can deploy microservices on Alibaba Cloud with Function Compute.

Deploy Microservices with Function Compute: Visitor Card of Cloud Customer Service

Alibaba Cloud's Cloud Customer Service is a complete intelligent service system that can be easily integrated into websites, applications, public accounts, and other systems. Cloud Customer Service provides complete hotline and online service functions for users to easily access other systems such as CRM. It dynamically manages the centralized knowledge bases and knowledge documents used by customers and agents. Based on Alibaba Cloud's intelligent algorithms, chatbots can accurately understand your intention and answer any questions. In addition, it collects and analyzes the data in the customer service center in real time, helping enterprise decision-makers understand the most common issues and service bottlenecks from a global perspective.

As a function of Cloud Customer Service, Visitor Card associates the users of Cloud Customer Service with those in the CRM system to help the customer service personnel understand the customers' basic information for better support.

The Visitor Card Integration Guide provided by Cloud Customer Service is a web project implemented based on Spring MVC. For users who use Node.js, they can migrate from Java to Function Compute and provide function as a service for core business calls implemented with Node.js.

Challenges

Users have tried to migrate Java by themselves but encountered the following technical challenges:

  1. JAR provided by Cloud Customer Service is a private Maven warehouse and cannot be accessed by the external network. Therefore, JAR must be copied to Maven for integration.
  2. How should the Maven plug-in be properly configured to generate a JAR package that is supported by Function Compute?

This article shows you how you can deploy microservices on Alibaba Cloud with Function Compute by using Cloud Customer Service as an example.

How to Migrate LibreOffice to Function Compute

LibreOffice [1] is a free and open source code office suite developed by the Documentation Foundation. The LibreOffice suite includes text processors, spreadsheets, presentation programs, vector graphics editors and chart tools, database management programs, and applications for creating and editing mathematical formulas. By using LibreOffice's CLI, Microsoft Office files can be easily converted to PDF files. See the following figure:

$ soffice --convert-to pdf --outdir /tmp /tmp/test.doc

The size of a full LibreOffice program is 2 GB. In Function Compute, however, the size of the /tmp cache directory is limited to 512 MB and that of the zip package is limited to 50 MB. Fortunately, the aws-lambda-libreoffice project [2] from the community has successfully migrated LibreOffice to the AWS Lambda platform. Based on the existing methods and experiences, I created the fc-libreoffice project, which enables LibreOffice to run on Alibaba Cloud's function calculation platform. fc-libreoffice resolves the following problems based on aws-lambda-libreoffice:

  1. Recompile and tailor LibreOffice to adapt it to the built-in gcc and kernel versions of the FC nodejn8 runtime environment.
  2. Install libssl3 dependencies that were missing during the runtime.
  3. Download and extract it during OSS runtime to override the 50 MB limit for ZIP packages.
  4. The example project has been created to support one-click deployment for a quick experience.

This document focuses on the entire migration process. It also records the key steps for migration to the function calculation platform in the future by using similar conversion tools. If you are interested in how to quickly build a cheap and scalable Word-to-PDF cloud service, see Launching a Word-to-PDF Cloud Service on Function Compute.

Launching a Word-to-PDF Cloud Service on Function Compute

Charging by the number of calls and dynamic scaling features makes Function Compute an ideal solution for deploying online conversion tools, such as image clipping, webpage-to-image, and text-to-audio tools. These conversion tools are usually implemented with CPP and eventually compiled into binary command tools or DLLs. Because Function Compute is remotely called over HTTP in multi-language runtime environments, it is also suitable for the heterogeneous mode.

fc-libreoffice is a NPM with nodejs-based interface encapsulation. It incorporates the built-in and pre-compiled LibreOffice for running Function Compute. LibreOffice is tailored and compressed by using the Brotli algorithm and with a high compression ratio. However, the compression package is 84 MB, exceeding the upper limit (50 MB) of Function Compute. Therefore, in the example, we use Object Storage Service (OSS) to upload the LibreOffice file and download and compress it before running.

This article explains how to quickly deploy a Word-to-PDF cloud service with LibreOffice and Function Compute, based on the fc-libreoffice project.

Related Products

Function Compute

Alibaba Cloud Function Compute is a fully managed, event-driven compute service. Function Compute allows you to focus on writing and uploading code without having to manage infrastructure such as servers. Function Compute provides compute resources to run code flexibly and reliably. Additionally, Function Compute provides a generous amount of free resources. No fees are incurred for up to 1,000,000 invocations and 400,000 CU-second compute resources per month.

Object Storage Service

Alibaba Cloud Object Storage Service (OSS) is an encrypted, secure, cost-effective, and easy-to-use object storage service that enables you to store, back up, and archive large amounts of data in the cloud, with a guaranteed durability of 99.9999999999%(12 9’s). RESTful APIs allow storage and access to OSS anywhere on the Internet. You can elastically scale the capacity and processing capability and choose from a variety of storage types to optimize the storage cost.

Related Documentation

What is Function Compute?

Alibaba Cloud Function Compute is a fully-managed event-driven computing service. With Function Compute, you can focus on writing and uploading code, without the need to procure and manage infrastructure resources such as servers. Function Compute prepares computing resources for you, runs code in an elastic and reliable way, and provides features such as log query, performance monitoring, and alert.

With Function Compute, you can quickly create any type of applications and services and only pay for the resources actually consumed when you run your code.

How to use Function Compute

This topic briefly describes how to use Function Compute. Function Compute allows you to quickly build applications by writing function code without the need to manage servers. With Function Compute, you can elastically scale computing resources.

0 0 0
Share on

Alibaba Clouder

2,599 posts | 762 followers

You may also like

Comments