Serverless is a prevalent buzzword among developers recently, but do you really know how to take full advantage of it? This tutorial will help you to create a small, serverless personal webpage by using Alibaba Cloud

What Is Serverless?

Serverless is a new computing paradigm in which you can build applications composed of microservices running as a response to events. Under this model, the services automatically scale according to the usage. This means that you only get charged when they are executed, becoming the most “pay-as-you-go” model ever. Of course, this reduces the overall cost of maintenance for your apps, enabling you to move on the logic, deploying faster.

The classic approach to publishing a website on your own is to have a web server, such as an Elastic Computer Service (ECS) instance, running non-stop. This means having an instance 24 hours a day, 7 days per week. Running the numbers, that is about 730 hours per month, between $5~$15 every month depending on the plan and, on top of that, all the security and software updates involved in managing a server. I’m sure you prefer to spend that time and money on something more enjoyable, like a day in the mountains instead.

What Will We Build in This Tutorial?

For the purpose of learning, we will keep things simple and clear by setting up a simple “About Me” page. For this, we will leverage Object Storage Service (OSS), API Gateway, Function Compute, and Table Store. To make that happen, the idea is to host a static HTML file in an OSS bucket with Public Read Permissions. This page will have a visit counter that will communicate via API Gateway with Function Compute, and keep the visits count on Table Store. Does it sound complex? Keep reading, you will find it easy.

Let’s Get Started

To start, create a folder for the project. Once inside it, create the file .env for the credentials and leave it there for now.

Install Fun

We said this tutorial will be based on “Fun.” Fun is an official Alibaba Cloud tool to arrange serverless applications resources. Therefore, we will use it to deploy our website backend by describing the resources in a template.yml file.

To install Fun, you only need to run in your terminal npm install @alicloud/fun -g. To verify that the installation went ok, type fun -h   and see if the output prints the Fun help.

Leave a comment

Your email address will not be published. Required fields are marked *