×
Community Blog Yuchuan Technology Explains Why They Use Function Compute

Yuchuan Technology Explains Why They Use Function Compute

This article introduces Yuchuan Technology and explains why they use Function Compute.

By Huang Bei (Yuchuan Technology CTO) and Luo Hao (Alibaba Cloud Architect)

Shenzhen Yuchuan Technology Co., Ltd. is a comprehensive Internet marketing and promotion provider focusing on precision marketing and Internet ecological product operation. Yuchuan Technology provides multi-level services for enterprises (including traffic matrix construction and operation, media traffic purchase, commercial model design, product marketing planning, data monitoring and analysis, and effect operation) by integrating high-quality media resources across the network and combining intelligent data models and AI tag algorithms. In this article, the CTO and Technical Director of Yuchuan Technology discussed the Serverless journey of Yuchuan Technology.

Currently, the business of Yuchuan Technology is mainly based on lightweight and easy-to-use Alipay applets, and their contents can be updated quickly. Higher requirements are proposed for agile development to adapt to the rapid changes in the market and changing customer demands. The business characteristics of Yuchuan Technology contain large fluctuations in visits and difficult traffic burst predictions. In particular, the sudden increase in visits during promotions is a big test for the stability and elasticity of the backend services of applets.

Alibaba Cloud Function Compute (FC) is a typical Serverless computing platform with strong elasticity. It can scale over a hundred milliseconds and support elastic business expansion. At the same time, users can upload code to run Function Compute without paying attention to and maintaining the server, which improves the backend development efficiency. These features make Function Compute a preferred choice for many enterprises to support applets/mobile apps, especially in business scenarios with sudden traffic or large traffic fluctuations.

The following is the Serverless landing practice based on the first perspective of Yuchuan Technology.

How Do Complex Interactive Applets Cope with the Visit Surge?

At the end of 2018, we started to adopt Function Compute. At that time, the company’s core business was to make some applets on Alipay. The Multiple Gifts applet was launched at that time. It is an applet that focuses on getting gifts with interactions.It has accumulated millions of users per day, becoming a popular product. However, when Multiple Gifts was first launched in 2018, we encountered the problem of sudden traffic increases that were difficult for the existing business system to bear.

At that time, our businesses were all on the server. We prepared about three or four high-configuration servers for load balancing to withstand high concurrent traffic. However, service collapses still occurred during the peak of the concurrent business. This applet involves a lot of business logic and interactions with the application backend, and there are many complex processes, such as clock-in, sign-in, and manor operation. Therefore, it is difficult to withstand the sudden increase in traffic by simply increasing the number of servers.

In addition, we encountered the problem of low resource utilization. When Multiple Gifts was launched in the initial stage, the concurrency in the peak period was about 1000-2000, but it may only be dozens in the low period. This happened because the user clock-in and sign-in and other actions required by the applet made the user visit prone to surge in the morning, evening, or at a specific time. In this case, if we use ECS, we need to reserve enough ECS resources according to the peak traffic, which makes the maintenance complicated. As a result, resource utilization is difficult to increase, and the cost will increase exponentially.

Therefore, we were eager to decouple this problem from our system, and it would be nice if we could simplify our O&M complexity and introduce elasticity capabilities. After investigating, we found that only Alibaba Cloud Function Compute had the corresponding characteristics at that time. Then, we tried to move the whole business to Alibaba Cloud Function Compute. After more than three years, we have successfully migrated new applications, old applications that can be migrated, and internal and external applications to Function Compute in succession. It can be said that once Function Compute breaks down, our company’s business basically collapses. During these three years of use, the stability of Function Compute was beyond expectations. Compared with the time when we maintained and used servers, the business stability and performance improved significantly. Now, during the peak traffic period, the QPS can reach tens of thousands, and thousands of functions can run concurrently and stably. Moreover, we have established a dedicated technical support group with Function Compute. Any technical problems can receive a quick response. This is why we dare to deploy all the business of our company based on Function Compute. Function Compute helps us solve many problems of stability and performance.

1
A Page from the Multiple Gifts Applet

Best Practices

We will share some best practices for Function Compute, hoping to help other users use Function Compute.

1. Development Process

The main technology stack of our company is based on the PHP language, and some Web frameworks are used as well, such as Lavaral. In order to run the Web framework on Function Compute successfully, we have made some adaptations to the framework. One project is split into one or several files corresponding to multiple functions. A single file contains 10,000 lines of code, and a basic file contains about 100 lines. Now, Function Compute (with the Serverless Devs tool) supports the “0” transformation migration of multilingual Web frameworks, which we are trying to use. 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 depend on functions across services, but we will run them independently as much as possible. Function Compute supports the layer function. Later, the layer will be used to deploy public functions and dependencies (such as sending red packets to users), with code writing only once. In addition, the Function Compute threshold is not so high for the newly recruited developers. They can directly edit code, deploy, and test online without managing the server and building the environment.

2. Pipeline and Canary Release

The SVN store code and SVN commit code we have been using locally support triggering Action. We encapsulate the Function Compute API, and the release of functions and services can be triggered using keywords. We use the version and alias functions of Function Compute to avoid the release affecting online services. Normal online services will be released into a new version, and the release alias bound to the HTTP traffic portal will point to the new version. Thus, the release is completed. If there is a problem with the latest code, change the alias to roll back to the previous version with one click. At the same time, we will create a test alias. After the version testing, the release alias that carries the current network traffic will point to the new version. As such, the online environment and the test environment are distinguished by the alias, which is convenient.

3. O&M Management

With the Function Compute’s elasticity that we rely on most, we don’t need to care about resource maintenance. However, monitoring logs has become a critical method for business O&M. Function Compute is integrated with SLS. A log is generated for each request, and error logs can be easily filtered out, which is convenient for online troubleshooting. In addition, Function Compute provides a relatively complete monitoring view. The most commonly used metrics are the number of requests, errors, concurrency, and execution time. Alerts are also added for the number of errors. This way, development can be directly combined with business O&M, and the efficiency is doubled.

Effect Comparison

Compared with the previously used servers, Function Compute has brought a lot of conveniences. We are the vanguards, growing up with Function Compute. We are happy to see that the functions of Function Compute are getting richer, and the user experience is getting better.

Summary

1. Stability Enhancement

Developers do not need to care about the construction and O&M of backend services. They only need to write functions to provide applets with stable, reliable, and auto scaling services. As the visits of applets increase, Function Compute can support a larger concurrency quota. Our applets can run smoothly even during the traffic peak caused by large promotions. The improvement of stability is the greatest help to us.

2. Easy to Use, No Server Maintenance

The characteristic of Function Compute that says, “easy to use, no server maintenance,” is an attractive point for us. Many people have misunderstandings about Serverless technology. They believe this hot technology may be difficult to learn and understand, but it is not. In actual use, we tried to let some new developers use Function Compute during production, and they mastered the platform quickly. They only needed to care about their code, so they were very pleased to use it.

3. Technical Support Worth Buying, with Low Prices and Good Service

Before, we did not make detailed statistics on the cost of Function Compute. We just found that the cost of Function Compute for an applet supporting more than 500,000 people a day is about 200 yuan per day. This cost is low with regard to our business. We encountered some problems in daily use, but the Function Compute Team provided timely and patient technical support. I once joked with my team that I wanted to spend more money on Function Compute and buy its technical support team.

The Real Elastic Computing in the Cloud Computing Era

The biggest advantage of Serverless technology is that it is free of O&M and provides elasticity and a pay-as-you-go charging mode. We chose Serverless because we think it is a future trend. If we use products (such as ECS) and our business development needs to be increased, we need to manually start machines or implement some auto scaling policies. However, Serverless enables us to realize auto scaling without considering all the O&M work at the backend. Therefore, we think Serverless is the real elastic computing in the cloud computing era.

Finally, we would like to make some suggestions for Function Compute:

  1. It is expected that the call entry of Function Compute can support the fixed IP access. IP black-and-white lists need to be added because of government regulatory requirements.
  2. The Release of the Function Version: It is expected that Function Compute can support accurate release for a single function. Thus, a more accurate canary release can be implemented.
0 1 0
Share on

Alibaba Cloud Serverless

99 posts | 7 followers

You may also like

Comments

Alibaba Cloud Serverless

99 posts | 7 followers

Related Products