By Afzaal Ahmad Zeeshan, 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.
More than that of the personal experience we rely upon the experts' evangelicals and views, and the same theme has accounted for Monolithic applications and architectures since after the prevalent of some certain buzzwords like microservices, containers and serverless architecture. Undoubtedly, monolithic applications are notoriously complex to manage and deploy, updating and scaling larger applications sound like a massively troubling task, however, its biggest flaw is the biggest reason to support it. The monolith architecture is simply perfect for small applications because it would be easy to maintain, and its problems would relatively easy and predictable—meaning that the problems arise as our application grows and complexity. For the applications that are either small or demand no frequent changes, or the applications for which we do not know the complete domain and scope, I found monolith pattern even better for the following reasons:
But when your application goes beyond the normal size, then you need to draw some domains, and sketch the areas where you are going to break the application down to smaller levels. That is when you create the services and develop in a service-oriented pattern. These services in modern day are known as the microservices. The reason I am mentioning microservices, is because serverless and microservices are often confused and used interchangeably.
Serverless approach although focused and resembles the microservices, or service-oriented architecture in the simplicities, deployment and inter-service-communication. But serverless more likely is a practice, like DevOps. In serverless approach, we write our applications targeting the best possible outcome in terms of performance, and lesser overhead and wait-times in the overall execution of our request. As a developer, our role is to write the software that utilizes the cloud platform to its fullest. In the same time, we also target to decrease the overall cost of our solutions.
On the cloud, the cost is charged based on several factors,
These three main areas of the cloud are the ones that incur charges. Serverless aims to minimize this, and it does so by,
Serverless approaches on Alibaba Cloud take the same step for our applications. Alibaba Cloud provides us with the Alibaba Function Compute service, that can be extended to support a complete application deployment in miniature microservices, that conform to all the requirements that we have on the cloud environment.
Before we start with the Alibaba Cloud Function Compute, it is better to explain the serverless concept, and how serverless helps organizations do more and pay less on their cloud budget. Also, one thing, this is not an Alibaba Cloud Function Compute starter guide, to learn how to create a function please check out one of our other posts on Alibaba Cloud, in this post we will discuss how Alibaba Cloud Function Compute can be used to migrate your existing monolith APIs to serverless functions.
So far, we have covered a lot about monolith applications and about the reasons that why they should not be distinct, and why they should be a preferable choice for small-scale applications. Now think with the perspective of bigger products, mega applications and larger projects, such as enterprise applications, which is your only goal and market demand. How will you scale and manage them, would easily they be built and deployed or is it even sensible to replicate whole of the application at times when there are changes in only one or two modules. To be specific, it is too much complicated and hard to manage an ever growing and ever scaling application which is based on monolithic architecture. In most cases, you generally start with a monolith application and once in production you distribute the workload one by one and create separate modules—which are services—and deploy them separately. Most organizations utilize approaches like domain-driven design and generate domains for each service and separate them out.
Writing code sophisticatedly had become the norm in almost every software company. However, this isn't a bad practice but if this sophistication comes along with the fear that what if other things will get affected by making any kind of changes in any specific module, due to coupled and dependent code then this sophistication cannot be taken positively, especially in an ever-growing environment. For monolithic application, even the senior developers do hesitate while making changes without being extremely worried about performance of overall application in the production because they know tweaking in any of the module can be risky and can make them sit for long hours to track what is making your application crashed.
So, we need something less dependent, decoupled and easy to build and develop architecting model, which is the actual topic of this article.
Not since quite recently but it has been quite many years now that every big and widespread computing concept, or normally startups starts with cloud, but we cannot make cloud computing our ultimate solution for everything. Similarly, the fact that putting our monolith application on the cloud will solve out the issues—which we have discussed above—is useless and unjustifiable. Because, we would need highly skilled and trained team to tackle cloud infrastructure, moreover, maintenance, security and configuration of load balancers would be highly costly, which is cumbersome and a proof that 'There is no use of putting monolith applications AS-IT-IS on the cloud'.
Somehow and somewhat, we all have used software engineering design pattern in any of our projects. All these patterns are designed to fulfill a specific kind of problem and requirement. In, the same way we do have various kind of cloud pattern depending upon the user need and usage. From the wide variety of these design patterns the one which has usurped the monolith pattern and resolve the scalability and management issues of such large applications is serverless pattern. And this is the pattern that Alibaba Cloud Function Compute provides us with.
Serverless is not only about the development of the solutions in a distributed and service-oriented fashion, but it also helps us manage, and in most cases even help us decrease the cost of the cloud infrastructure that we have purchased. In the next sections, we will explore how scalability happens on the Alibaba Cloud Function Compute and how we can deploy our solutions online.
Serverless computing is getting high popularity not only among the individuals and companies but every huge industry is showing its interest to support and commercialize the products based on serverless concepts. Similarly, Function Computer – is the Alibaba's service to leverage cloud computing based on the serverless pattern.
Functions are small chunks of code which get executed on the cloud for some specific problem, we do not need to worry about building and deploying entire application and infrastructure to make the changes render. Business productivity, customer support and overall management become a lot easier, moreover we can have the support of multiple languages like NodeJS, Python, Java and PHP, this diversified runtime support provides a flexibility and more control over development strategies and patterns. This enables you to quickly lift-and-shift your existing APIs and deploy them right away to the Alibaba Cloud Function Compute. For example, the following image shows the supported runtimes,
From simple APIs to larger integrated applications such as IoT and microservices based scalable projects, function compute is great way to process data and synthesize information. Function compute provides us various template to get started with our scenarios.
Among lots of sounding features, Pay-As-You-Go and auto-scaling are the two most attractive functionalities. Function compute is an event-driven, fully managed and scaled hosted environment. It disentangles developers from the burden of managing infrastructures, servers and traffic load, so that they can have an expeditious process of write and run their code directly in the production.
Management means setup, configurations, infrastructure setting and then issue fixing, when every resource will be busy in this so how business will grow, and team's productivity will be showcased? So, function compute provides all sort of management and monitoring. It supports the 'Pay as you go' billing strategy which is usurping the other models, where you will have to pay only for the seconds and minutes when you're using the computing resources.
Now let us also discuss a bit about the runtimes that are supported on Alibaba Cloud, for the serverless development. On most major scenarios, where usually you must write the functions, Alibaba Cloud offers you a set of runtimes, the most common and important are:
It is up to the taste and personal satisfaction, as to which language of choice one must select. My favorite among these is Node.js, with 8th version of Node.js we get everything for a modern cloud-native application—which can easily help us to build, develop and deploy the solutions, and at the same time manage the cost of our applications too, using async/await keywords.
Now let us get a bit serious into the post. A serverless function must be executed via some method, a trigger, or a call to it—just like an ordinary function. But here is the fun part, instead of being executed by internal code, it can be triggered as a standalone task. This is the beautiful property of serverless architecture, especially Alibaba Cloud Function Compute. The following image depicts this concept and shares the available triggers.
This gives us the flexibility to either expose our functions to the outside world, or just keep the triggers in the VPC on Alibaba Cloud. In this fashion, if we utilize the HTTP-based triggers, we can rewrite each individual API endpoint as a function. So, imagine in this way that your own APIs are being written as,
If you already have an API that corresponds to this URL endpoint list, then you can see that these can be quickly upgraded to functions. Now with functions, you get 2 benefits:
The second point is what gives the actual benefit of using the serverless functions approach with Alibaba Cloud Function Compute. In this approach, your functions are separate tasks and process running and serving the clients. Just because the GET request to /person/all, needed to scale, does not require that you also add more resources for a POST /person, function that is merely getting any request. So, instead of a complete scale of your instances, you only scale a single process and rest of the functions do not get additional resources—unless they need, of course. For example, the following screenshot demonstrates how a single service can be used as a hosting for an API, and each endpoint and HTTP verb can be a functional unit,
This service can contain extra functions such as this image demonstrates,
This way we can create as many extra functions as we need, and they will be independent of each other, in terms of development and deployment.
Alibaba Cloud also offers that you attach these serverless tasks with other resources on the cloud too. Meaning, that instead of having to send an HTTP request to the function, you can attach these hooks to other resources like OSS, RAM, etc. and have the function react to the changes. This is although a less useful way, because you are no longer supplying your APIs, but this is a useful way to utilize a cloud-watcher-like service on the cloud. For example, the trigger selection page lets you specify the sort of trigger you want,
And you can specify the type of trigger you want. Since we wanted to discuss the HTTP triggers, we selected the HTTP one to create the APIs, you can utilize other modes and try them out too.
Alibaba Clouder - January 12, 2021
Alibaba Container Service - August 25, 2020
Alibaba Clouder - June 9, 2020
Alibaba Clouder - October 20, 2020
Alibaba Clouder - September 24, 2020
Alibaba Developer - September 7, 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
API Gateway provides you with high-performance and high-availability API hosting services to deploy and release your APIs on Alibaba Cloud products.Learn More
An online computing service that offers elastic and secure virtual cloud servers to cater all your cloud hosting needs.Learn More
More Posts by Alibaba Clouder