The author | li source (yuan yi) | Serverless public number

Event Driven Framework: Knative Eventing

Event-driven refers to a strategy that events make decisions in the process of continuous transaction management. Recurring problems can be solved by mobilizing available resources to perform related tasks. In layman’s terms, a response to a user’s behavior when a user triggers a use behavior. In the Serverless scenario, event-driven fits perfectly with one of its original designs: pay-as-you-go.

1. Knative model

Figure: Knative model

Knative is mainly composed of two parts: one is the Serving of the workload, including version management, grayscale flow, and automatic elasticity; The second is Eventing (event-driven framework).

  • The core players

    • Google;
    • IBM;
    • Pivotal.
    • RedHat.
    • SAP.
  • Friends related products

    • Google CloudRun;
    • IBM;
    • Pivotal Function Service (PFC);
    • OpenShift.

2. Event Driven Framework: Eventing

Knative Eventing provides a complete event model that facilitates access to events from various external systems. After the Event is connected, the Cloud Event standard is used for internal flow and the broker-trigger model is used for Event processing.

As you can see from the diagram above, Eventing has three parts:

  • The event source
  • ** Broker-trigger: ** Event-driven model. This model has been around since the early 16 years. Triggers subscribe to Broker information, filter it, and finally send events to the corresponding service for consumption.
  • ** Message system: ** A system of messages corresponding to each Broker in Eventing that carries the entire flow of events. Current community-supported messaging systems include Kafka, NATS, Rocket MQ, Rabbit MQ, and more.

3. Key features: Event rules

At the heart of event rules is the broker-trigger model, which contains the following features:

  • The function of Trigger filter is to filter the content of events.
  • Supports filtering of Event attributes and Data contents.
  • Support for Common Expression Language (CEL) Expression filtering;
  • Filter by SourceAndType (event source type).

Event-driven engine – event source

1. Event source description

The Knative community provides rich access to event sources, including Kafka and Github, as well as access to events from messaging cloud products, such as MNS and RocketMQ.

As shown in the figure above, once the event source is connected, the corresponding service can be requested through the broker-trigger model. These services include scenarios such as building images from source code, automated image publishing, AI audio and video processing, and scheduled tasks. All events need such an event source to be pulled and then sent to Eventing throughout the event flow.

  • The event access

    • Access message cloud product event sources;
    • Events to access more cloud products via MNS.
  • The event processing

    • Knative Eventing implements internal subscription, filtering, and routing mechanisms for events;
    • Events are ultimately consumed through the Knative managed Serverless service.
  • Typical cases

    • AI audio and video processing;
    • Code submission automatically builds the image.

2. RocketMQ event source

RocketMQ version of message queue is a distributed message middleware with low latency, high concurrency, high availability and high reliability built by Ali Cloud based on Apache RocketMQ.

Message queue RocketMQ not only provides asynchronous decoupling and peak-filling capabilities for distributed applications, but also features massive message stacking, high throughput, and reliable retry for Internet applications.

RocketMQSource is the RocketMQ event source for the Knative platform. It can forward RocketMQ cluster messages to the Knative platform in real time in the form of Cloud events. It is the connector between Apahe RocketMQ and Knative.

3. Kafka event source

Message queue Kafka version is a distributed message queue service with high throughput and high scalability built by Ali Cloud based on Apache Kafka. It is widely used in log collection, monitoring data aggregation, streaming data processing, online and offline analysis, etc. It is one of the indispensable products in the big data ecology. Ali Cloud provides full hosting services. Users do not need to deploy O&M, which is more professional, reliable, and secure.

Iii. AI event-driven scenario practice

Take a specific scene as an example. This case is a live broadcast system. The system has a large number of live broadcast visits every day. Customer demands: first, business flexibility and high message concurrency; Second, interactive real-time response requires low latency.

In order to meet the requirements of flexible fluctuation, high concurrency and low delay in message processing, customers choose The Knative service of Ali Cloud for elastic data processing. Ali Cloud Knative fully meets the current demands of users, and provides flexible scheduling based on events and messages on the basis of access to K8s standard.

When the number of application instances expands and shrinks with service peaks and troughs, the on-demand and real-time flexibility is achieved. The entire process is fully automated, reducing the infrastructure burden on business developers. In this case, Knative provides three main capabilities: extreme flexibility, event handling, and out of the box.

The following is an example demonstration, which mainly includes:

  • Deploy the Kafka event source
  • Deploy event Gateway
  • Deploy the service
  • Simulated event processing

Demonstration to watch links: developer.aliyun.com/live/246128

Author introduction: Peng Li, Name: Yi Yuan, senior development engineer of Ali Cloud Container Platform, joined Ali in 2016, deeply involved in alibaba’s comprehensive containerization and supporting double Eleven containerization link for many years. It focuses on cloud native areas such as containers, Kubernetes, Service Mesh and Serverless, and is committed to building a new generation of Serverless platform. Currently, I am responsible for the work related to Ali Cloud container service Knative.