×
Community Blog Flexibly Managed Compute Resources Using Function Compute

Flexibly Managed Compute Resources Using Function Compute

Function Compute is a serverless compute platform which can help you build a serverless website, manage and monitor your own website elastically.

How to Use Function Compute on Alibaba Cloud

This tutorial explains the differences between conventional server-based cloud computing and serverless Function Compute, and then shows you how to use it step-by-step.

Welcome

This tutorial explains the concept of the Function Compute facility on Alibaba Cloud, and then shows you how to use it step-by-step. The tutorial also explains the differences between conventional server-based cloud computing and serverless Function Compute, to help you understand the various methodologies.

Prerequisites

To follow this tutorial you'll need an Alibaba Cloud account. If you don't already have one, sign up for a free account through this link. Alibaba Cloud provides a Free Trial for you explore various products worth $300-1200 USD depending on your account type.

From Servers to Functions

Business and enterprise IT has conventionally been based around the concept of servers. Companies' data centers contained web servers, database servers, DNS servers, LDAP servers, file servers, print servers, mail servers, and many more. A server was originally a physical box, but in recent years the move to virtualization technology meant that many servers became virtual machines, or VMs, instead. Some servers provided a single function, such as database or web, while others provided multiple functions in order to utilize resources more efficiently or to keep costs down.

As business IT moved to the cloud, and in-house data centers relocated to become Virtual Private Clouds, the concept of a server being the basic building block remained in place. In-house web servers became cloud-based web servers, in-house database servers migrated to the cloud unchanged, and so on.

Over the past couple of years, server-based cloud computing has been joined by a new way of operating, known as serverless computing. The basic building block is no longer a server but a single block of code, known as a function, which is run whenever a particular event, known as a trigger, occurs. A customer simply uploads functions to a cloud provider's infrastructure and triggers them as required. There are no servers to build, maintain, secure or patch. There's no need for scaling and load-balancing, as this all happens automatically behind the scenes on the cloud provider's infrastructure. You can trigger a function once per week or a million times per hour, and the underlying systems will handle it all.

Function-based serverless computing on Alibaba Cloud is known as Function Compute, and it's available to use right now. This tutorial will show you how, step by step.

How Billing Works

Billing for Function Compute is on a pay-as-you-go model and is based on the number of times you trigger a function, its resources used, and any Internet traffic that the function uses.

Using Function Compute to implement a specific feature is incredibly cost-effective. Triggering a function costs USD $0.20 per million triggers, with your first million triggers free each month. Internet traffic costs between $0.07 and $0.13 per GB, depending on which hosting region you use.

Resources are measured in gigabyte-seconds, which is the amount of memory you allocated to the function, multiplied by the time it took to run (to the nearest 100 ms). Your first 400,000 GB-seconds each month are free of charge which, for example, gives you 1.6 million invocations of a function that runs for one second, if it's been allocated 256MB.

The Case for Serverless

The easiest way to understand function-based serverless computing is to consider some cases where it might be used. For example:

  1. A logged-in user clicks a link on your website. You want to record details of which link was clicked and who clicked it. The click triggers a function which adds this information to a database.
  2. A user of a trivia quiz app, running on a smartphone, clicks the answer to a question. This triggers a function which looks up the answer in a database and returns the relevant result to the user.
  3. A home owner presses a button on his or her Internet-connected thermostat to view historical data. This triggers a function which retrieves the data from a database and sends it to the IoT device to display.
  4. A timer-based trigger runs a function every few minutes to send outgoing emails that were placed in a queue by another process.
  5. A user of a "smart speaker" requests a particular song. The smart speaker triggers a function, via the function's unique URL, which fetches the correct MP3 file from a server and sends it to the speaker to play.
  6. When a user uploads a file to a shared file store, the action of uploading the file triggers a function which compresses it in order to save disk space.

As you can see, serverless function-based computing doesn't necessarily replace existing servers. More often than not, conventional servers work alongside serverless trigger-based functions.

As to the choice of language runtime, Function Compute currently supports PHP, Python, Node.js and Java.

Related Blogs

Create a Serverless Website with Alibaba Cloud Function Compute

In this tutorial, we'll show you how to create a serverless website with Alibaba Cloud's Function Compute.

What Is Alibaba Cloud's Function Compute?

Alibaba Cloud's Function Compute is a fully-managed, event-driven compute service for serverless applications. With Function Compute, developers can focus on writing and uploading code without having to worry about building an underlying infrastructure or maintaining complicated server architectures.

Alibaba Cloud's Function Compute event-driven service has near limitless applications, including API gateways, data lake analysis, log stores and backups, web crawlers and image recognition, to name a few. With Function Compute, developing is convenient and reliable. Function Compute supports many different programming languages including Java, Python, PHP, and NodeJS.

Alibaba Cloud's Function Compute provides real-time auto scaling and dynamic load balancing inside millisecond timeframes for managing traffic bursts. The compute resources available make code flexible and reliable. Furthermore, Function Compute offers a Pay-As-You-Go option which means you are charged for consumed resources only. No fee is incurred if the code doesn't run. Moreover, the run duration is measured in milliseconds.

A few common business scenarios for Alibaba Cloud's Function Compute include analysis and management of media assets, for example integrating a range of services that run an elastic and highly available backend video system. Another common scenario is building a serverless backend that triggers Function Compute code to render dynamic webpages. Furthermore, these web applications can hook up to APIs when Function Compute is integrated with Alibaba Cloud's API Gateway. Another interesting business scenario is using Function Compute to manage real time IoT message processing and monitoring of data streams.

What Is Serverless?

Serverless is a new paradigm in cloud computing. Serverless applications running on Alibaba Cloud's Function Compute provide custom code that runs in managed containers so there is no need to maintain costly, always-on, traditional servers. This reduces operational costs and complexity.

The Serverless Framework is an open-source project from MIT supporting the serverless development paradigm. The Serverless Framework allows cloud developers to build BaaS (Backend as a Service) applications comprised of microservices running in response to events. These applications auto-scale and are billed only when they run, which lowers the maintenance costs and enables developers to build applications faster.

The Serverless Framework for well-known cloud services plugs into event-driven cloud compute services such as Alibaba Cloud's Function Compute. It is a command-line tool, providing scaffolding, workflow automation, and best practices for developing and deploying serverless architectures. It also has a plugin architecture for extensibility.

Alibaba Cloud's Serverless Framework API is called Fun. Fun allows you to do everything you can do in the Alibaba Cloud Function Compute UI console but from the command line instead. You can learn more about Fun at https://www.alibabacloud.com/help/doc-detail/64204.htm

In this tutorial, we will look at building a simple website application with Alibaba Cloud's Function Compute in the UI console.

Prerequisites

You will need an Alibaba Cloud account. If you don't already have one, head over to the Free Trial page to get $300-1,200 worth of Alibaba Cloud products to play around with in the Alibaba Cloud Free Trial.

Let's go ahead and set up Function Compute and build a serverless website.

Monitoring SSL Certificates with Alibaba Cloud Function Compute

In this tutorial, we will learn how to use Alibaba Cloud Function Compute and DirectMail to automatically monitor SSL certificates for your websites.
By John Hanley, Alibaba Cloud Tech Share Author. Tech Share is Alibaba Cloud’s incentive program to encourage the sharing of technical knowledge and best practices within the cloud community.

After working with Alibaba Cloud services, you may find that you have dozens or hundreds of services that depend on SSL certificates. This can include Elastic Compute Service (ECS) instances, websites, API Gateway services, Function Compute functions, and CDN endpoints. This article will discuss how to monitor SSL certificates and send emails on the status of your SSL certificates. We will use Function Compute and DirectMail for automation, monitoring and reporting.
This article is an add-on to my series of using Let's Encrypt SSL Certificates on Alibaba Cloud. These certificates expire after 90 days, therefore, keeping track of certificate expiration dates is very important. However, tracking services that use SSL certificates is mundane, tedious and we often forget about them. In another article, we will develop software that can automatically renew Let's Encrypt SSL certificates.
The goal of this article is to show you how to do this. The code is not production quality, rather it is education quality. All software that you plan to deploy for production purposes needs to be reviewed and tested for quality and suitability for your requirements.
This article assumes that you have a basic understanding of Alibaba Cloud Function Compute and DirectMail. If not, I have written this article to help you understand these services. The last part of this tutorial shows how to speed up testing and updates using the Alibaba Cloud FCLI command line program.

SSL Monitor Python Code Download

Download the Python code that will be used in this tutorial by clicking on this link: SSL Check - Python 3 (Zip - 10 KB)
Last Update: June 24, 2018
Requirements: Python 3.6 or newer (Python 2 is not supported)
Platforms: Tested on Windows 10 and Function Compute
Note: Antivirus software will complain about this download because it is a zip file with Python source code.
SSL Certificate Status Report

Let's start by reviewing what this program generates. The following table is generated by this code and emailed to an email address that you specify. The report has 5 columns of information. Each row describes the status for one hostname. Notice that the last line is in yellow. This line includes the error message that the host is unreachable. I included the hostname "bad.neoprime.xyz" to generate this error on purpose.

Using Log Service with Alibaba Cloud's Function Compute

In this tutorial, we will show you how to create an Alibaba Cloud Log Service project which triggers an Alibaba Cloud Function Compute function.

What Is Alibaba Cloud's Function Compute?

Alibaba Cloud's Function Compute is a fully-managed, event-driven compute service for serverless applications. Developers focus on writing and uploading code without having to worry about building the underlying infrastructure or maintaining complicated server architectures.

Alibaba Cloud's Function Compute service has a range of applications on offer, including API gateways, data lake analysis, log stores and backups, web crawlers and image recognition, to name just a few. With Function Compute, developing is convenient and reliable. Function Compute supports many different programming languages including Java, Python, PHP, and NodeJS.

Alibaba Cloud's Function Compute provides real-time auto scaling and dynamic load balancing for managing heavy traffic bursts within millisecond timeframes. The compute resources offered make code flexible and reliable. Furthermore, Function Compute offers a Pay-As-You-Go option which means that you only have to pay for consumed resources. No fee is incurred if the code doesn't run. Moreover, the code run duration is measured in milliseconds.

A few common business scenarios for Alibaba Cloud's Function Compute include analysis and management of media assets, for example integrating a range of services that run an elastic and highly available backend video system. Another is building a serverless backend that triggers Function Compute code to render dynamic webpages and static webpages housed in Alibaba Cloud's Object Storage Service. Web applications like these also have the capability to connect to external APIs when Function Compute is integrated with Alibaba Cloud's API Gateway. Another interesting business scenario is implementing Function Compute to manage real time IoT message processing and monitoring of data streams.

What Is Alibaba Cloud's Log Service?

Alibaba Cloud's Log Service is a logging service available for use with Alibaba Cloud products and services. Applications built on Alibaba Cloud connect to a ready-made Log Service Logstore which efficiently configures and manages log collection and maintenance. Log Service is the Alibaba Cloud one stop shop for all Alibaba Cloud product logging requirements.

Alibaba Cloud's Log Service is a powerful solution for collecting, consuming, transferring, querying, and analyzing massive amounts of logging data with minimal development effort. The improvements to the operational efficiency of log management for all kinds of scenarios, including big data scenarios, means that developers can focus more of their time on their business requirements.

Alibaba Cloud's Log Service provides a user-friendly interface for accessing the real-time log data it consumes from services and applications. Log data is viewable as metrics, events, binary logs, text logs, and click data. Log Service is ideal for database ETL (extract, transform, load), streaming, monitoring and alarm, machine learning and iterative computing.

How Do Log Service and Function Compute Fit Together?

With Alibaba Cloud's Function Compute, you can create a function that connects to a Log Service project in the same region. The Function Compute function sets a trigger on the Log Service and then listens for events coming in from the Log Service project.

Once the Log Service job is up and running, it works on a timer principle which polls Alibaba Cloud Logstore shard information at regular points in time – every second, for example. The Function Compute trigger executes the function configured in Function Compute on a regular basis or when given specific input parameters.

Prerequisites

You will need an Alibaba Cloud account. If you don't already have one, head over to the Free Trial page to get $300-1,200 worth of Alibaba Cloud products to play around with in the Alibaba Cloud Free Trial.

Let's get started.

Using API Gateway with Alibaba Cloud's Function Compute

In this tutorial, we will show you how to build an Alibaba Cloud Function Compute function for use by Alibaba Cloud's API Gateway service. We will use Function Compute to create a function that returns a result to the API Gateway service we set up. We will also show you how to monitor your Alibaba Cloud API Gateway service directly from the Function Compute console.

What Is Alibaba Cloud's Function Compute?

Alibaba Cloud's Function Compute is a fully-managed, event-driven compute service for serverless applications. It allows developers to focus on writing and uploading code without having to worry about building and managing complicated infrastructure or operating and maintaining server setups.

Alibaba Cloud's Function Compute service can run many different types of applications, including API gateways, data lake analyses, log stores and backups, web crawlers, and image recognition applications, to name just a few. With Function Compute, developing is convenient and reliable. Function Compute supports many different programming languages including Java, Python, PHP, and NodeJS.

Alibaba Cloud's Function Compute provides real-time auto scaling and dynamic load balancing for managing heavy traffic bursts within millisecond timeframes. Its compute resources ensure that code is flexible and reliable. Furthermore, Function Compute offers a Pay-As-You-Go option which means that you only have to pay for the resources you consume. No fee is incurred if the code doesn't run. Moreover, the code run duration is measured in milliseconds.

Some common business scenarios for Alibaba Cloud's Function Compute include analysis and management of media assets, such as integrating a range of services that run an elastic and highly available backend video system. Another scenario might be to have a serverless backend that triggers Function Compute code which then renders dynamic and static webpages housed in Alibaba Cloud's Object Storage Service. We can also connect Function Compute web services like these to Alibaba Cloud's API Gateway. One further interesting business scenario is implementing Function Compute to manage real time IoT message processing and the monitoring of data streams.

What Is Alibaba Cloud's API Gateway?

Alibaba Cloud's API Gateway service is a fully functional API hosting service that allows you to publish your APIs centrally and offer them to your clients and partners. You can also release your APIs on the Alibaba Cloud API marketplace where other developers may purchase them.

Alibaba Cloud's API Gateway service is a full API lifecycle management service. It provides API definition and publishing, testing, release, and removal. It can generate SDKs and API instructions and has a visualized debugging tool. Alibaba Cloud's API Gateway service increases the efficiency of API management and iterative release. It allows enterprises to flexibly and securely share their technological innovations leaving them free to focus on strengthening and advancing their businesses.

The API Gateway service provides multiple security and efficiency options that include attack defenses, anti-replay, request encryption, identity authentication, permission management, and throttling. Furthermore, Alibaba Cloud's API Gateway service has convenient maintenance, observation, and measurement tools, such as monitoring, alarms, and analysis. It also enables speedy and reliable microservice integration, front and back end separation, and robust system integration at low cost.

Alibaba Cloud's API Gateway service is the ideal service for publishing your APIs and integrates well with other Alibaba Cloud products and services.

Prerequisites

You will need an Alibaba Cloud account. If you don't already have one, head over to the Free Trial page to get $300-1200 worth of Alibaba Cloud products to play around with in the Alibaba Cloud Free Trial.

Using Alibaba Cloud's Network Attached Storage (NAS) with Function Compute

In this tutorial, we will show you how to read and write data to Alibaba Cloud's Network Attached Storage (NAS) service from an Alibaba Cloud Function Compute serverless function.

What Is Alibaba Cloud's Function Compute?

Alibaba Cloud's Function Compute is a fully-managed, event-driven compute service for serverless applications. Developers focus on writing and uploading code without having to worry about building the underlying infrastructure or maintaining complicated server architectures.

Alibaba Cloud's Function Compute service has myriad applications, including API gateways, data lake analysis, log stores and backups, web crawlers and image recognition, to name just a few. With Function Compute, developing is convenient and reliable, and it supports many different programming languages including Java, Python, PHP, and NodeJS.

Alibaba Cloud's Function Compute provides real-time auto scaling and dynamic load balancing for managing heavy traffic bursts within millisecond timeframes. The compute resources offered make code flexible and reliable. Furthermore, Function Compute offers a Pay-As-You-Go option which means you only have to pay for consumed resources. No fee is incurred if the code doesn't run. Moreover, the code run duration is measured in milliseconds.

A few common business scenarios for Alibaba Cloud's Function Compute include analysis and management of media assets, such as integrating a range of services that run an elastic and highly available backend video system. Another is building a serverless backend that triggers Function Compute code to render dynamic webpages and static webpages housed in Alibaba Cloud's Object Storage Service. Web applications like these also have the capability to connect to external APIs when Function Compute is integrated with Alibaba Cloud's API Gateway. Another interesting business scenario is implementing Function Compute to manage real time IoT message processing and monitoring of data streams.

What Is Network Attached Storage (NAS)?

Alibaba Cloud's Network Attached Storage (NAS) is a file storage service that supports standard file access protocols. This means you don't have to modify existing applications; both Windows and Linux applications can use the NAS service.

Alibaba Cloud's NAS service is extremely reliable and guarantees high throughput and low latency. NAS gives you a distributed file system with unlimited capacity as well as performance scaling. Simple and easy to use, NAS provides mount points that connect to Alibaba Cloud Elastic Compute Service nodes residing on VPCs. The mount points allow programmers to perform file operations as if the files were stored locally.

With Function Compute, we will demonstrate the ease with which you can prepare code to access Alibaba Cloud's Network Attached Storage. We will demonstrate read and write operations in Python, although a number of languages are available.

Related Courses

Using Function Compute To Acquire Users Registration Info

This course is designed to assist users who want to get knowledge of serverless computing technology, and who like to use cloud product to apply data processing. In this course, users can understand what is serverless compute, the advantage of function compute, and can apply function compute to satisfy simple business demands.

Using Function Compute To Quickly Build An Image Processing Service

This course is associated with Deploy an image process service using Function Compute. You must purchase the certification package before you are able to complete all lessons for a certificate.

Cross Region OSS Replication With Function Compute

How to easily achieve cross region data replication on Alibaba Cloud OSS? You’ll learn it in this short video with a quick demo.

A Demo of How to Use Function Compute HTTP Trigger

In this online course, you will learn how to configure Alibaba Cloud Function compute product using its embedded HTTP trigger, so that when request is sent to a particular URL, your predefined actions will be triggered automatically

Related Market products

Using Function Compute To Acquire Users Registration Info

Through this course, you can understand advantages and usage scenarios of Alibaba Function Compute, and be able to apply this product to satisfy simple business demands.

Introduction to Network Attached Storage

By the end of this course, you will be able to plan, configure and administer file storage using Alibaba Cloud Network Attached Storage (NAS).

Related Documentation

What is Function Compute

Alibaba Cloud Function Compute is an event-driven and fully-managed compute service. With Function Compute, you can quickly build any type of applications or services without considering management or O&M. You can complete a set of backend services for processing multimedia data even in several days.

How it works

By using Function Compute, you can author and upload codes without worrying about procuring and managing infrastructure resources. Function Compute prepares computing resources for you and runs your codes on your behalf elastically and reliably.

In addition, Function Compute provides log query, performance monitoring, alarms, and other features.

You only pay for resources actually consumed when running the codes. No fee is incurred for application codes that are not run.

Integration

Function Compute integrates different services in an event-driven manner. When the event source service triggers an event, the associated function is automatically called to process the event.

You can trigger function invocation by using OSS, Log Service, API Gateway, Table Store, or Function Compute SDK and API. With these services and features, you can easily build elastic, reliable, and secure applications. For more information about the type of event sources supported by Function Compute, see Trigger List.

For example, if new data is uploaded to your Alibaba Cloud OSS, a function is automatically called to respond this event. In addition, API gateway can be used to trigger a function for HTTP requests. You can also use the Function Compute SDK and API to call your codes.

Operations in Function Compute

This topic describes the basic operations in Function Compute. Function Compute allows you to quickly build an application by writing function code, meaning no server management is required. Additionally, Function Compute supports elastic scaling. You can use services on a Pay-As-You-Go basis.

Developer tools

Function Compute supports the following tools: command-line tool fcli, command-line tool fun, and console. You can use fcli or the console to build services or query logs.

Related Products

Function Compute

A secure and stable, elastically scaled, O&M-free, pay-as-you-go, serverless computing platform.

NAT Gateway

NAT Gateway is an enterprise-class public network gateway, providing proxy services (SNAT and DNAT), up to 10 Gbps forwarding capacity, and cross-zone disaster recovery. NAT Gateway helps you establish an Internet gateway for a VPC by configuring SNAT and DNAT entries, allowing more flexible use of network resources.

1 0 0
Share on

Alibaba Clouder

2,605 posts | 747 followers

You may also like

Comments

Dikky Ryan Pratama May 8, 2023 at 3:54 pm

I wanted to take a moment to express my gratitude for the wonderful article you recently published on Alibaba Cloud Blog. Your writing was engaging and insightful, and I found myself fully immersed in the content from start to finish.The way you presented the information was both informative and easy to understand, which made it an enjoyable read for me. Your hard work and dedication to providing high-quality content are truly appreciated.Thank you once again for sharing your knowledge and expertise on this subject. I look forward to reading more of your work in the future.