Fish technology function calculation
Shenzhen Yuchuan Technology Co., Ltd. is a comprehensive internet marketing and promotion service provider focusing on precision marketing and internet ecological product operation. By integrating high-quality media resources across the network and combining intelligent data model and AI tag algorithm, it provides enterprises with multi-level services including traffic matrix construction and operation, media traffic purchase, delivery model design, product marketing planning, data monitoring and analysis, and effect operation. As a senior user of function computing, the CTO and technical director of YuChuan Technology talked with us about the Serverless journey of YuChuan Technology.
At present, Yuchuan Technology's business is mainly based on the Alipay applet. The applet is lightweight, easy to open, and its content can be updated quickly. In order to adapt to the rapid changes in the market and changing customer demands, it puts forward higher requirements for agile development. The business characteristics of YuChuan Technology are also characterized by large fluctuations in traffic volume and difficulty in traffic burst prediction. Especially, the sudden increase of visits during the event is also a great test for the stability and flexibility of the back-end services of the applet. Alibaba Cloud functional computing is a typical Serverless computing platform with strong flexibility, which can achieve 100-millisecond elastic expansion and can well support business elastic expansion. At the same time, for function calculation, users can upload the code and run it without paying attention to and maintaining the server, which also greatly improves the back-end development efficiency.
These features make function computing a priority choice for many enterprises to support applications/mobile apps, especially in business scenarios with sudden traffic or large traffic fluctuations. The following is the implementation practice of Serverless based on the first perspective of YuChuan Technology.
How do complex interactive applets cope with the surge in traffic?
At the end of 2018, we began to use function calculation. At that time, the core business of the company was to make some small programs on Alipay. At that time, the small program "Duoduo You Li" was launched. "Duoduo You Li" is a small program that focuses on interactive awards. At present, it has accumulated the scale of millions of days, and is a very popular product for users. However, in 2018, when "How courteous" was initially launched, we encountered the problem that the existing business system could not bear the sudden increase in traffic. At that time, our business was running on the server. In order to resist the high concurrent traffic, we prepared about three or four highly configured servers for load balancing. However, during the peak of business concurrency, the service crash often occurred. Because this application involves a lot of business logic and interaction with the application backend, and there are many complex processes, such as clocking, check-in, manor operation, etc., it is difficult to cope with the sudden increase in traffic and simply increase the number of servers.
In addition, we also encountered the problem of low resource utilization. When "How courteous" was launched in the early stage, the number of concurrent users was about 1000-2000 at the peak of the business, but the number of concurrent users at the low peak of the business was probably dozens. This is because the number of users was very easy to increase sharply in the morning, evening, or at a specific time because of the actions such as user clocking in and signing in. In this case, if we use ECS again, we not only need to reserve enough ECS resources according to the peak traffic, but also the maintenance will become very complex, the resource utilization rate is difficult to achieve, and the cost will increase exponentially. So we were very eager to decouple this matter from our system. If only we could simplify our operation and maintenance complexity and introduce flexibility.
After investigation, we found that at that time, Alibaba Cloud only had functional computing FC with corresponding features, so we began to try to move the entire business to Alibaba Cloud functional computing. After more than three years of use, we have migrated new applications, old applications that can be migrated, and internal/external applications to function computing. It can be said that if the function calculation collapses, our company's business will basically collapse. However, after three years of use, it is found that the stability of function calculation is still beyond expectations. Compared with the time when we maintain and use the server, the business stability and performance have been greatly improved. Now the peak value can reach tens of thousands of QPS, thousands of functions simultaneously and stably. In addition, we have also established a special technical support group with function computing. Any technical problem can be responded to quickly. That is why we dare to deploy all businesses of the company based on function computing. Using function calculation really helps us solve many stability and performance problems.
"How kind" applet page
Best Practices
Let's share some of our best practices in using function calculation. I hope it can also help other users to use function calculation.
1. Development process
Our company's main technology stack is based on the PHP language, and also uses some Web frameworks, such as Laval. For the Web framework, in order to run on the function calculation, we have also made some adaptations to the framework. A project is split into one or more files, corresponding to multiple functions. A single file has 10000 lines of code, and the basic file has about 100 lines. But now, function calculation and Serverless Devs tools support the "0" transformation and migration of multilingual web framework, and we are also trying to use it.
At present, each developer will be responsible for a function service independently. Each function under the service will be used as a small application. Some projects will rely on some function functions across services, but we will try to be independent. The function calculation also supports the layer function. The layer will be used later to deploy public functions and dependencies, such as sending red packets to users. Only one copy of the code will be written. In addition, for the newly recruited development, the threshold for function calculation is still very low. You can directly edit code, deploy and test online without managing the server environment.
2. Pipeline and grayscale release
The SVN storage code that we have been using locally, and the SVN submission code supports triggering Action. We encapsulate the API interface for function calculation, which can trigger the release of functions and services through keywords. In order to avoid the impact of publishing on online services, we also use the function of calculating version and alias. The normal online business will be released to a new version. At the same time, the release alias bound to the HTTP traffic entry will be directed to the new version. This completes the release process. If there is a problem with the latest code, you can change the direction of the alias to achieve one-click rollback to the previous version. At the same time, we will also create a test alias. After the version test is completed, the release alias that carries the current network traffic will be pointed to the new version. In this way, the online environment and the test environment can be distinguished by the ability of aliases, which is very convenient.
3. Operation and maintenance management
For function calculation, we don't need to care about resource maintenance, such as our most dependent flexibility. But for business operation and maintenance, monitoring log has become a very critical means. SLS is integrated into function calculation. Each request will generate a log, which can easily filter out error logs. It is also convenient to troubleshoot online problems. In addition, the function calculation also provides a relatively comprehensive monitoring view. The most commonly used indicators are the number of requests, the number of errors, concurrency, and execution time. An alarm is also added for the number of errors, so that the development can be directly used for business operation and maintenance, and the efficiency is multiplied.
Effect comparison:
Compared with the previous use of servers, function computing has really brought us great convenience. We are also the first people to eat crabs, and we have grown along with function computing. We are also very happy to see that function computing has more and more functions and better experience. To summarize:
1. The stability enhancement development does not need to care about the establishment, operation and maintenance of back-end services, but only needs to write functions to provide stable, reliable and elastic services for small programs. And as the number of small program accesses increases, the function calculation can support a larger concurrent quota, and it can be smooth even when dealing with the peak traffic of large promotion activities. For the improvement of stability, this is the biggest help for us.
2. We are also attracted by the fact that we are quick to develop and do not need to maintain the server. Many people have some misunderstandings about "Serverless" technology, and think that this hot technology may be difficult to learn and understand, but it is not. In the process of actual use, we have tried to let some new developers use function calculation directly in the production process. In the process of practical operation, these developers are very quick. They only need to care about their own code and are very happy to use it. 3. The price is low and the service is good. Before we want to buy technical support, we didn't make detailed statistics on the use cost of function calculation. We just found that the cost of using function calculation is about 200 yuan/day for a small program that supports more than 500000 people a day. This cost is still very cheap for our business. We also encounter some problems in daily use. The function calculation team can provide technical support in a timely and patient manner. I once joked with my classmates that I especially want to spend more money on function calculation and buy technical support.
True elastic computing in the cloud computing era
The biggest advantage of Serverless technology is that it is free of operation and maintenance, while providing flexibility and pay-as-you-go. We choose to use Serverless because we think it is true elastic computing and the future trend. If I use products such as elastic ECS, if my business development needs to increase, I need to "start" the machine manually or implement some elastic strategies. However, Serverless allows me to realize automatic elastic scaling without considering all the operation and maintenance work of the back end, so we think Serverless is the true elastic computing in the cloud computing era.
Finally, we also want to make some suggestions for function calculation:
1. It is expected that the call entry of function calculation can support the fixed access IP, because some government regulatory requirements require the addition of black-and-white IP lists.
2. The function version release can support the precise release of a single function to achieve more accurate grayscale.
At present, Yuchuan Technology's business is mainly based on the Alipay applet. The applet is lightweight, easy to open, and its content can be updated quickly. In order to adapt to the rapid changes in the market and changing customer demands, it puts forward higher requirements for agile development. The business characteristics of YuChuan Technology are also characterized by large fluctuations in traffic volume and difficulty in traffic burst prediction. Especially, the sudden increase of visits during the event is also a great test for the stability and flexibility of the back-end services of the applet. Alibaba Cloud functional computing is a typical Serverless computing platform with strong flexibility, which can achieve 100-millisecond elastic expansion and can well support business elastic expansion. At the same time, for function calculation, users can upload the code and run it without paying attention to and maintaining the server, which also greatly improves the back-end development efficiency.
These features make function computing a priority choice for many enterprises to support applications/mobile apps, especially in business scenarios with sudden traffic or large traffic fluctuations. The following is the implementation practice of Serverless based on the first perspective of YuChuan Technology.
How do complex interactive applets cope with the surge in traffic?
At the end of 2018, we began to use function calculation. At that time, the core business of the company was to make some small programs on Alipay. At that time, the small program "Duoduo You Li" was launched. "Duoduo You Li" is a small program that focuses on interactive awards. At present, it has accumulated the scale of millions of days, and is a very popular product for users. However, in 2018, when "How courteous" was initially launched, we encountered the problem that the existing business system could not bear the sudden increase in traffic. At that time, our business was running on the server. In order to resist the high concurrent traffic, we prepared about three or four highly configured servers for load balancing. However, during the peak of business concurrency, the service crash often occurred. Because this application involves a lot of business logic and interaction with the application backend, and there are many complex processes, such as clocking, check-in, manor operation, etc., it is difficult to cope with the sudden increase in traffic and simply increase the number of servers.
In addition, we also encountered the problem of low resource utilization. When "How courteous" was launched in the early stage, the number of concurrent users was about 1000-2000 at the peak of the business, but the number of concurrent users at the low peak of the business was probably dozens. This is because the number of users was very easy to increase sharply in the morning, evening, or at a specific time because of the actions such as user clocking in and signing in. In this case, if we use ECS again, we not only need to reserve enough ECS resources according to the peak traffic, but also the maintenance will become very complex, the resource utilization rate is difficult to achieve, and the cost will increase exponentially. So we were very eager to decouple this matter from our system. If only we could simplify our operation and maintenance complexity and introduce flexibility.
After investigation, we found that at that time, Alibaba Cloud only had functional computing FC with corresponding features, so we began to try to move the entire business to Alibaba Cloud functional computing. After more than three years of use, we have migrated new applications, old applications that can be migrated, and internal/external applications to function computing. It can be said that if the function calculation collapses, our company's business will basically collapse. However, after three years of use, it is found that the stability of function calculation is still beyond expectations. Compared with the time when we maintain and use the server, the business stability and performance have been greatly improved. Now the peak value can reach tens of thousands of QPS, thousands of functions simultaneously and stably. In addition, we have also established a special technical support group with function computing. Any technical problem can be responded to quickly. That is why we dare to deploy all businesses of the company based on function computing. Using function calculation really helps us solve many stability and performance problems.
"How kind" applet page
Best Practices
Let's share some of our best practices in using function calculation. I hope it can also help other users to use function calculation.
1. Development process
Our company's main technology stack is based on the PHP language, and also uses some Web frameworks, such as Laval. For the Web framework, in order to run on the function calculation, we have also made some adaptations to the framework. A project is split into one or more files, corresponding to multiple functions. A single file has 10000 lines of code, and the basic file has about 100 lines. But now, function calculation and Serverless Devs tools support the "0" transformation and migration of multilingual web framework, and we are also trying to use it.
At present, each developer will be responsible for a function service independently. Each function under the service will be used as a small application. Some projects will rely on some function functions across services, but we will try to be independent. The function calculation also supports the layer function. The layer will be used later to deploy public functions and dependencies, such as sending red packets to users. Only one copy of the code will be written. In addition, for the newly recruited development, the threshold for function calculation is still very low. You can directly edit code, deploy and test online without managing the server environment.
2. Pipeline and grayscale release
The SVN storage code that we have been using locally, and the SVN submission code supports triggering Action. We encapsulate the API interface for function calculation, which can trigger the release of functions and services through keywords. In order to avoid the impact of publishing on online services, we also use the function of calculating version and alias. The normal online business will be released to a new version. At the same time, the release alias bound to the HTTP traffic entry will be directed to the new version. This completes the release process. If there is a problem with the latest code, you can change the direction of the alias to achieve one-click rollback to the previous version. At the same time, we will also create a test alias. After the version test is completed, the release alias that carries the current network traffic will be pointed to the new version. In this way, the online environment and the test environment can be distinguished by the ability of aliases, which is very convenient.
3. Operation and maintenance management
For function calculation, we don't need to care about resource maintenance, such as our most dependent flexibility. But for business operation and maintenance, monitoring log has become a very critical means. SLS is integrated into function calculation. Each request will generate a log, which can easily filter out error logs. It is also convenient to troubleshoot online problems. In addition, the function calculation also provides a relatively comprehensive monitoring view. The most commonly used indicators are the number of requests, the number of errors, concurrency, and execution time. An alarm is also added for the number of errors, so that the development can be directly used for business operation and maintenance, and the efficiency is multiplied.
Effect comparison:
Compared with the previous use of servers, function computing has really brought us great convenience. We are also the first people to eat crabs, and we have grown along with function computing. We are also very happy to see that function computing has more and more functions and better experience. To summarize:
1. The stability enhancement development does not need to care about the establishment, operation and maintenance of back-end services, but only needs to write functions to provide stable, reliable and elastic services for small programs. And as the number of small program accesses increases, the function calculation can support a larger concurrent quota, and it can be smooth even when dealing with the peak traffic of large promotion activities. For the improvement of stability, this is the biggest help for us.
2. We are also attracted by the fact that we are quick to develop and do not need to maintain the server. Many people have some misunderstandings about "Serverless" technology, and think that this hot technology may be difficult to learn and understand, but it is not. In the process of actual use, we have tried to let some new developers use function calculation directly in the production process. In the process of practical operation, these developers are very quick. They only need to care about their own code and are very happy to use it. 3. The price is low and the service is good. Before we want to buy technical support, we didn't make detailed statistics on the use cost of function calculation. We just found that the cost of using function calculation is about 200 yuan/day for a small program that supports more than 500000 people a day. This cost is still very cheap for our business. We also encounter some problems in daily use. The function calculation team can provide technical support in a timely and patient manner. I once joked with my classmates that I especially want to spend more money on function calculation and buy technical support.
True elastic computing in the cloud computing era
The biggest advantage of Serverless technology is that it is free of operation and maintenance, while providing flexibility and pay-as-you-go. We choose to use Serverless because we think it is true elastic computing and the future trend. If I use products such as elastic ECS, if my business development needs to increase, I need to "start" the machine manually or implement some elastic strategies. However, Serverless allows me to realize automatic elastic scaling without considering all the operation and maintenance work of the back end, so we think Serverless is the true elastic computing in the cloud computing era.
Finally, we also want to make some suggestions for function calculation:
1. It is expected that the call entry of function calculation can support the fixed access IP, because some government regulatory requirements require the addition of black-and-white IP lists.
2. The function version release can support the precise release of a single function to achieve more accurate grayscale.
Related Articles
-
A detailed explanation of Hadoop core architecture HDFS
Knowledge Base Team
-
What Does IOT Mean
Knowledge Base Team
-
6 Optional Technologies for Data Storage
Knowledge Base Team
-
What Is Blockchain Technology
Knowledge Base Team
Explore More Special Offers
-
Short Message Service(SMS) & Mail Service
50,000 email package starts as low as USD 1.99, 120 short messages start at only USD 1.00