Serverless Function Computing Helps Enterprises Reduce Costs and Improve Efficiency


As one of the infrastructures in the PaaS field of cloud computing, Message Queuing Service (named after Message Service below) has attracted more and more attention from developers for its high concurrency, peak shaving and valley filling characteristics. The Message Service accepts the request of the message producer service on the upper side and connects the consumer service on the lower side. When it comes to consumption, we have to introduce two questions?

1. How to transmit message data from Message Service to downstream consumer services in a low-cost, high-throughput and low-latency way?

2. How to quickly build a message consumption service that is free of operation and maintenance and flexible on demand?

Today, let's talk about how to build such a system on Alibaba Cloud based on Serverless computing service+Message Service.

Noun interpretation

Function Compute

Alibaba Cloud function computing is an event-driven fully hosted serverless computing service. Through function calculation, you don't need to manage infrastructure such as servers, just write code and upload it. Function calculation will prepare computing resources for you to run your code in an elastic and reliable manner. For more product details, please read the official document [1].


Connector implements the import and export of a large amount of data. For example, export the data in KAFKA topic to stdout, or import the data in the local file to RocketMQ. Connector simplifies the complexity of data replication and transmission between different systems. The connection between message services and computing services discussed in this article also depends on Connector.


The event bus is a product service of Connector, which supports the standardized and centralized access of Alibaba Cloud services, custom applications, SaaS applications, etc., and can route events between these applications using standardized protocols, helping you easily build a loosely coupled and distributed event-driven architecture. For more product details, see the official document [2].

Architecture evolution

The traditional data consumption architecture is shown on the left:

1) The data source writes the generated data to the message system;

2) Developers read data from Message Service with the help of OpenAPI/SDK or Proxy service client provided by Message Service;

3) According to the message data processing business logic, which is what we call consumption message, the business result of message consumption is written to the target service; So architecture developers will face the following problems:

1. How to read data from Message Service concurrently and safely?

2. When the data consumption capacity is less than the production capacity, how to quickly improve consumption throughput?

3. When the target service resource becomes a bottleneck, how to quickly expand the capacity? After the traffic peak, how do you deal with the idle machine cost?

4. How to ensure real-time and sequential consumption?

5. How to achieve high availability protection measures such as fault tolerance, cache, degradation, and current limitation?

6. How to monitor the link status or abnormality?


In the face of the above trivial and complex problems, I believe there will always be a few that will hit your pain points. In order to solve all the problems mentioned at the same time, Alibaba Cloud developed the Connector Service (as shown in the right figure above) to connect the data link between the Message Service and the Serverless computing service. You only need to declare the upstream message service instance and the downstream consumer operator to deploy online with one click. The connector also provides the data processing and monitoring capabilities of the rich streaming computing framework, which are summarized as follows:

Transform: customize data cleaning logic in UDF mode, and support JsonPath syntax to simply extract data;

1. Filter: reduce the subsequent processing of useless messages, and provide a variety of filter matching rules, such as: prefix matching, numerical matching, IP address matching, etc;

Window: provides the window capability to aggregate and push messages according to the number of messages and the interval time. It can improve message processing throughput and reduce message processing costs;

Real Time: the delay level of milliseconds from pulling messages from the Message Service to pushing the target service;

Custom concurrent consumption capability: concurrent and safe consumption messages to improve throughput;

Elastic computing resources: downstream computing services automatically expand and shrink capacity according to the load, and do not need to care about the server resource water level;

Monitoring+Logging+Tracing: provides rich monitoring indicators and log analysis to help developers monitor system status and locate exceptions;

Complete exception protection mechanism: user-defined retry strategy+fault-tolerant mechanism+dead letter queue+current limit+anti-pressure;

In order to give you a deeper understanding of the functions, let's introduce the benefits and application scenarios of each function in detail.

Cost reduction and efficiency improvement function


In large-scale data scenarios, One Message Per Request has long been unable to meet the needs of developers. The essence of Window is to provide the ability to process messages in batches. Connector provides two configurable parameters at the product level:

• Number of messages pushed in batch: the maximum number of messages aggregated at a time. Messages will be pushed to the downstream only when the number of messages in backlog reaches the set value.

• Batch push interval: the system will aggregate the backlog of messages and send them to the downstream at every interval time point. If 0 seconds is set, it means there is no waiting time, and it will be delivered upon receiving.

The combination of the two parameters can greatly improve the efficiency of data transmission, thus improving data throughput, and can unlock multiple user scenarios, for example:

• Streaming mode real-time consumption: Set the push interval to 0 s and the maximum number of push pieces to ensure that the data pulled from the upstream is pushed to the downstream target service in real time.

• In the scenario of sparse requests and insensitive delay, if you want messages to be saved and processed in batches, you can accept the consumption delay but do not want the delay time to be too long: if you only set the parameter of batch push number, it may be delayed too long in the trough period because the message is sparse for a long time and cannot reach the preset number of saved and batch pieces. At this time, you can introduce the batch push interval parameter to solve this problem.


Message consumption cannot be separated from data processing. The so-called data processing is to convert the original data into the target data through a certain process, which is called transformation. Usually, the original data is a large and complete set of information, while the target data is only a structured subset. The key is how to embed the ability of data cleaning and extraction. This connector provides a variety of conversion capabilities:

• Template: both the original data and the target data are structured data, and the data extraction and assembly rules are simple. You can complete the transformation with the template. The template also supports the JsonPath data extraction rules, as shown in the following figure:

• UDF (User Definition Function): For scenarios where the original data structure is complex and the data conversion process is complex, UDF can be used. In UDF mode, the service provider has only agreed on the parameter input protocol and parameter data structure of the function. How to clean the data in the function? What is the returned data structure?


Based on Serverless function calculation, you can quickly build a safe and reliable data consumption system. The system advantages are summarized as follows:

• Cost reduction

• Filter: reduce invalid message processing and calls to function calculation;

• Window: It provides the ability of message accumulation and batch processing to help better handle some messages in non-real-time and discrete scenarios, and also reduces the number of calls to function calculation;

• Pay-as-you-go: The pay-as-you-go feature of computing resources avoids the useless overhead of reserving machines for the peak in the peak and valley scenarios;

• Continuous price reduction: the function calculation will reduce the price of all charging items in the whole region in November by 12% - 47%, and will fine charge the memory and cpu;

• Improve efficiency

• R&D efficiency: Transform, UDF, Template, JsonPath and other capabilities unlock more business scenarios, avoid secondary development, help you quickly build the system, and will also embed more operators in the future, even can arrange operators;

• Data analysis efficiency: provide numerical retrieval, visual analysis and other capabilities. You can quickly realize event-based streaming query and analysis through simple guided interaction;

• Problem troubleshooting efficiency: the system provides rich observable capabilities, such as event track, event market, etc., to help you monitor and analyze the overall status of the business. In the future, it will also improve its capabilities from multiple dimensions such as indicator exploration, operation and maintenance monitoring, fault location, etc., to achieve more comprehensive system observability;

• Operation and maintenance efficiency: The millisecond automatic elastic scaling feature of Serverless computing instance allows you to completely get rid of the burden of resource operation and maintenance;

As cloud computing gradually moves towards full serverless, the connection between Message Service and Serverless computing will become closer. Now the maturity of Connector has lowered the development threshold of complex systems, enabling you to truly realize end-to-end full-link deep cloud access.

Related Articles

Explore More Special Offers

  1. 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

phone Contact Us