So far in this forum I have posted about OSS, MongoDB and Function Compute. This post serves as the final piece in the whole series of building a serverless application using Alibaba Cloud.
In the cloud computing history, we have seen databases, file storage, and servers are transitioned to the cloud. Business applications can be deployed and run completely on elastic and secure virtual cloud servers. Can it get any better? Introducing Function as a Service (FaaS). Instead of hosting an entire application on a server, developers now have another option to upload their “application logic” to the cloud without worrying about server provision and management. This serverless model can be far more cost-effective and flexible scaling capabilities.
- Focus on your application code instead of worrying about provisioning, configuring, and managing servers.
- Faster time-to-market
- Easily scaled out
- High availability and fault tolerance
- No execution, no pay.
In this model the whole application is running without any server instances. All essential components are managed in different Alibaba Cloud services. Each service is fully managed and does not require you to provision or manage servers. You only need to configure them together and upload your application code to Function Compute.
API Gateway 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.
Alibaba Cloud Function Compute is a fully-managed event-driven compute service that runs your application logic.
Alibaba Cloud ApsaraDB for MongoDB provides a secure and elastically scalable service to manage your database. Please refer to my previous post “Building a Serverless REST API with Function Compute and MongoDB” for more details about Function Compute and MongoDB on Alibaba Cloud.
As with other models, serverless framework has its owns pros and cons. You need to consider these drawbacks before moving forward.
You have to rethink the way to design your application logic and workflow since Function Compute functions are event driven and naturally stateless. The entire system now technically depends on separate functions calls triggered by different events.
For Function Compute’s ease of execution and reduction in cost, you lose control of your environment. 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 needs.
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). Tasks that require more than 10 minute execution time need to be divided into smaller batches. Traditional approach does not have these limits.
Startup latency: as functions are designed to run in containers, there is overhead required to jump start the environment which in turns adds up the execution time.
This post present the serverless application model where you can run your applications without servers by using and configuring different Alibaba Cloud services together. Whereas this architecture gives you the advantages of flexible scalability and high availability, it also requires careful design of your application structure and workflow as well as further attention to its technical limits to ensure high system performance.