By Nhi Ha, Alibaba Cloud Community Blog author.
This blog is part of a two-part tutorial series on how to build a sample serverless application on Alibaba Cloud. This blog is the first part. In it, we will go over the major concepts and architecture of a serverless application. We try to present these terms in a simple and approachable manner, so they everything's easier to understand. Of course, if you are already familiar with all of this stuff, you can skip this part and go straight on to the second part of this two-part tutorial series, where you'll directly learn how to build the sample serverless application on Alibaba Cloud. We will take the same approach to the second part of this series.
Throughout the history of cloud computing, slowly but surely things like databases, file storage, and servers have slowly transitioned to the cloud. Following this steady migration to the cloud, business applications likewise in increasing numbers can be deployed and run completely on elastic and secure virtual cloud servers. All of this takes away the hassle of having to manage and maintain on-premises data centers with physical servers and their supporting network infrastructure all by yourself or your relevant team. And now, with the recent release of the Function Compute service from Alibaba Cloud, things have got even easier and better. Let me explain exactly. Now, instead of hosting an entire application on a server, developers can alternatively upload their application logic to the cloud without worrying about server provision and management systems. Because of this, among other things, this serverless model can be far more cost-effective and offers flexible scaling capabilities.
As you can probably infer from its name, this new application architecture provides the capabilities to deploy and run your applications without the need of setting up and maintaining any server in the cloud. The entire application stacks will operate by relying on different cloud services.
Perhaps the most notable advantage of serverless architecture is that you do not have to provide or manage any servers. This means that you can do things without the need for server provision, which means eliminating the need for no server management. This gets rid of the headache of server and network configuration, access control, OS patching, security defence, load balancing and performance scaling, so on and so forth.
The advantage of all of this is that you can completely focus on your core product and business logic. As a result, as you could image, with serveless, companies and organizations can significantly reduce the time-to-market of their on-cloud applications. Adding to this, your applications can be automatically scaled out in a very flexible manner by expanding its memory or throughput. High availability and fault tolerance are also provided by default. Finally, this paradigm helps to achieve a lower operation cost as you only pay when you code is running. Yes you heard it right: if you're not executing your application, you don't need to pay for it.
Of course, as with other models, a serverless framework has its both pros and cons. You need to consider these drawbacks before moving forward. Let's discuss some of them here:
1. You have to rethink the way to design your application logic and workflow. This is especially the case if you want to use Alibaba Cloud's Function Compute because its functions are event-driven and, of course, also stateless. The entire system now technically depends on separate functions calls triggered by different events.
2. For all of serveless's, as well as Alibaba Cloud's Function Compute's ease of execution and reduction in cost, you also lose control of your environment. That is, you are able to install third-party packages and libraries that your code needs to run, but your hands are really tied in terms of custom OS, so on.
3. There are restrictions on execution time (10 minutes) and payload size (6 MB) as well as maximum number of functions that can be created under a single service (50 functions). Also, asks that require more than 10-minute execution times need to be divided into smaller batches. Traditional approaches, non-serverless ones, that is, do not have these kinds of limits.
4. Startup latency: as functions are designed to run in containers, there is much overhead required to jump start the environment, which in turn adds to the execution time needed.
In the serverless model, the whole application is running without any server-providing instances. All essential components are managed using various services provided by Alibaba Cloud. Each service is fully managed and does not require you to provision or manage servers.
Let's quickly go through the key components, all of which are Alibaba Cloud services, in this architecture:
1. Object Storage Service (OSS)
2. API Gateway
API Gateway provides you with high-performance and highly available API hosting services to deploy and release your APIs. It serves as an HTTP endpoint to front our Function Compute logic. This is a front door for users to access data, business logic, or functionality from your back-end services. Having said that, this service is responsible to authorize access permissions to your system with multiple authentication methods. It also supports security mechanisms such as anti-attack, anti-injection, anti-request replay, and anti-request tampering.
3. Function Compute
This is a fully-managed event-driven compute service that runs your application logic. It lets you run code without provisioning or managing servers. Function Compute prepares computing resources for you and runs your codes on your behalf elastically and reliably. You only pay for resources actually consumed when running the codes. If your code isn't executed, you don't pay.
Function Compute runs your code in response to events. When the event source service triggers an event, the associated function is automatically called to process the event.
4. ApsaraDB for MongoDB
Over the last few years, NoSQL has become increasingly popular. This model solves the impedance mismatch between the relational data structures (tables, rows, fields) and the in-memory data structures of the application (objects). Most importantly, NoSQL is designed to scale horizontally which makes it an excellent choice for modern web applications.
NoSQL could be categorized into 4 groups:
MongoDB is the most popular system within the document database group. As defined on mongodb.com
A record in MongoDB is a document, which is a data structure composed of field and value pairs. MongoDB documents are similar to JSON objects. The values of fields may include other documents, arrays, and arrays of documents.
Alibaba Cloud ApsaraDB for MongoDB provides a secure and elastically scalable service to manage your MongoDB database on the cloud.
This part of this two-part tutorial covers the concepts of the serverless application model. This model can be used to run your applications without servers by using and configuring different Alibaba Cloud services together. This architecture gives you the advantages of flexible scalability and high availability, but it also requires the careful design of your application structure and workflow as well as further attention to its technical limits to ensure high system performance.
Alibaba Clouder - September 6, 2019
Alibaba Clouder - June 23, 2020
Alibaba Clouder - November 23, 2020
afzaalvirgoboy - June 17, 2020
Alibaba Clouder - November 11, 2020
Alibaba Clouder - November 23, 2020
Alibaba Cloud Function Compute is a fully-managed event-driven compute service. It allows you to focus on writing and uploading code without the need to manage infrastructure such as servers.Learn More
An online computing service that offers elastic and secure virtual cloud servers to cater all your cloud hosting needs.Learn More
A secure, reliable, and elastically scalable cloud database service for automatic monitoring, backup, and recovery by time pointLearn More
More Posts by Alibaba Clouder