狠狠撸

狠狠撸Share a Scribd company logo
Serverless Event Streaming
With Pulsar Functions
Xiaolong Ran @wolfstudy
2019/12/08
? 开源项?爱好者,Go 语?爱好者

? TiDB -> BitMain -> StreamNative

? Apache Pulsar committer

? Go Functions

? pulsar-client-go

? pulsarctl

? …

? https://github.com/wolfstudy
Who am I
?录
Apache Pulsar 介绍
Apache Pulsar 架构
Go Function 的设计
Go Function 的实现
Go Function 使?示例
Pulsar Function Runtime
Pulsar Function Worker
What is Apache Pulsar
为什么要“造轮?”
? 没有系统能够解决遇到的问题和规模

? 多租户 - 百万 Topics - 低延时 - 持久化 - 跨地域复制

? 已有的系统存在的问题

? 分区模型紧耦合(存储和计算)- 不是云原?的设计

? 存储模型过于简单,强依赖?件系统

? I/O 不隔离:消费者在清除 backlog 的时候会影响其它?产者和消费者

? 运维太痛苦 - 替换机器、服务扩容需要强制 reblance 导致服务对外不可?

? 可能出现消息丢失的情况
Flexible Messaging
Flexible Messaging
? One data, di?erent ways to consume

? Queuing (aka stateless messaging)

? Shared (* RabbitMQ)

? Streaming (aka stateful messaging)

? Exclusive

? Failover (* Kafka)

? Key_Shared
Multi Tenancy
Geo-Replication
Cloud-native Architecture
计算存储分离
?独?扩展
? 瞬时失效恢复
? 扩容?需数据均衡
Pulsar View - Topic
Pulsar View - Partition
Pulsar View - Segment
Event Stream is the right foundation for your data
Apache pulsar ?态
When Event Streaming
Meets Serverless
Introduce Pulsar Functions
Pulsar Functions
? A serverless event streaming framework

? Lightweight computation

? Event - ?rst, Stream - ?rst

? Multi languages

? Multi runtimes

? SDK - less && SDK
Pulsar Functions
Pulsar Functions
Pulsar Functions
Pulsar Functions
反射 Plugin
Pulsar Functions
反射
Plugin
? Go 是??静态类型的语?

? 反射?持的相对较弱
? 注??法模块,会带来?定安全隐患

? 如果模块出现问题,会导致服务奔溃

? 给版本管理带来了困难

? 社区不成熟
Go functions User Rule
func ()
func () error
func (input) error
func () (output, error)
func (input) (output, error)
func (context.Context) error
func (context.Context, input) error
func (context.Context) (output, error)
func (context.Context, input) (output, error)
Go functions User Rule
Start() 函数的?参必须是函数类型
?户函数的输?参数可以是 0-2 个
如果有两个参数,第?个必须是 context.Context
如果只有?个输?参数,必须是 context.Context
?户函数的输出参数可以是 0-2 个
如果返回两个参数,第?个参数必须是 error
如果只返回?个参数,必须是 error
Go functions Context
Go functions - Use Case
Go functions - Use Case
Pulsar Functions - CLI
Go functions - Close channel
没有简单易?的?法去检查管道是否没有通过改变它的状态来
关闭。
关闭?个已经关闭的管道会触发 panic,所以,关闭者不知道
管道是否关闭仍去关闭它,这是?个危险的?为。
发送数据到?个关闭的管道会触发 panic, 所以,发送者不知
道管道是否关闭仍去发送消息给它,这是?个危险的?为。
原则:要在 producer 端关闭 channel
Pulsar functions 使?场景
ETL
Data Enrichment
Data Filtering
Dynamic Routing
Alerts and Threholds
Flexible Runtime
Colocate with Broker - Thread & Process
Managed Function Workers - Thread & Process
External Schedulers - Container
Kubernetes
Colocate with Brokers
Manager Function Workers
External Schedulers - Kubernetes
Auto load balancing
Pulsar Functions use Pulsar’s auto-balancing
mechanism on consumer
Shared Subscription
Failover Subscription
Key-Shared Subscription (feature)
Pulsar Function worker
Pulsar Function worker
? 存放元数据信息

? 接收并存储 Function 所有的状态请求

? 为了防? topic 变?,写?时会进?压缩

? 所有数据使? FQFN 作为 key 写?
Pulsar Function worker
? 存放调度分配信息

? 接收并存储 leader 监听到的所有状态请求

? 使?垃圾收集,防? topic 变?

? 所有 worker 会订阅 assignment topic
Pulsar Function worker
? 管理 Functions Worker 的 Membership

? 每?个 Functions Worker 都会订阅 Coordination Topic

? Pulsar Broker 会跟踪处于活跃状态的 consumer

? 通过查询活跃状态的 consumer,获取所有处于活跃状
态的 Functions Worker
Complex Event Processing Pipelines
Community
? Mailing lists:
dev@pulsar.apache.org
users@pulsar.apache.org
? Github:
https://github.com/apache/pulsar
https://github.com/apache/pulsar-translation
? Slack:
https://apache-pulsar.slack.com/
https://apache-pulsar.herokuapp.com/
? WeChat
Apache Pulsar Users(China)
Apache Pulsar Users(global)
Thanks
Ad

Recommended

Opening Remarks - Pulsar Summit Asia 2021
Opening Remarks - Pulsar Summit Asia 2021
StreamNative
?
Improvements Made in KoP 2.9.0 - Pulsar Summit Asia 2021
Improvements Made in KoP 2.9.0 - Pulsar Summit Asia 2021
StreamNative
?
碍补蹿办补的设计与实现
碍补蹿办补的设计与实现
wang xing
?
The Evolution History of RoP(RocketMQ-on-Pulsar) - Pulsar Summit Asia 2021
The Evolution History of RoP(RocketMQ-on-Pulsar) - Pulsar Summit Asia 2021
StreamNative
?
RabbitMQ on Pulsar's Practice in Tencent Cloud - Puslar Summit Asia 2021
RabbitMQ on Pulsar's Practice in Tencent Cloud - Puslar Summit Asia 2021
StreamNative
?
lua & ngx_lua 的介绍与应用
lua & ngx_lua 的介绍与应用
hugo
?
Large-Scale Cluster Mangement & Kubernetes Under The Hood
Large-Scale Cluster Mangement & Kubernetes Under The Hood
Lei (Harry) Zhang
?
基于翱辫别苍搁别蝉迟测的百万级长连接推送
基于翱辫别苍搁别蝉迟测的百万级长连接推送
OpenRestyCon
?
Kafka in Depth
Kafka in Depth
YI-CHING WU
?
Kafka cluster best practices
Kafka cluster best practices
Rico Chen
?
Ansible 101
Ansible 101
YI-CHING WU
?
Monitor is all for ops
Monitor is all for ops
琛琳 饶
?
Openstack nova
Openstack nova
Yong Luo
?
The Application of OpenStack in 360buy, by Bin He
The Application of OpenStack in 360buy, by Bin He
Hui Cheng
?
深入浅出Netty l.t
深入浅出Netty l.t
oleone
?
基于贵耻别濒的超融合一体机
基于贵耻别濒的超融合一体机
EdwardBadBoy
?
Using armeria to write your RPC
Using armeria to write your RPC
koji lin
?
Docker
Docker
旭 張
?
Traffic server overview
Traffic server overview
qianshi
?
高性能奥别产服务器狈驳颈苍虫及相关新技术的应用实践
高性能奥别产服务器狈驳颈苍虫及相关新技术的应用实践
rewinx
?
20081128 http caching_in_php
20081128 http caching_in_php
Hunter Wu
?
DAE
DAE
Qiangning Hong
?
顿辞耻产濒别叠颈苍濒辞驳方案
顿辞耻产濒别叠颈苍濒辞驳方案
Lixun Peng
?
Openstack neutron 原理详解
Openstack neutron 原理详解
Yong Luo
?
Oh K8s Is Swag - Kubernetes Basics
Oh K8s Is Swag - Kubernetes Basics
Okis Chuang
?
How to upgrade_ror3_to_ror4
How to upgrade_ror3_to_ror4
Wei-Yi Chiu
?
JCConf2015: groovy to gradle
JCConf2015: groovy to gradle
Ching Yi Chan
?
Ansible introduction
Ansible introduction
Chyi-Shian Jiang
?
Is Using KoP (Kafka-on-Pulsar) a Good Idea? - Pulsar Summit SF 2022
Is Using KoP (Kafka-on-Pulsar) a Good Idea? - Pulsar Summit SF 2022
StreamNative
?
Building an Asynchronous Application Framework with Python and Pulsar - Pulsa...
Building an Asynchronous Application Framework with Python and Pulsar - Pulsa...
StreamNative
?

More Related Content

What's hot (20)

Kafka in Depth
Kafka in Depth
YI-CHING WU
?
Kafka cluster best practices
Kafka cluster best practices
Rico Chen
?
Ansible 101
Ansible 101
YI-CHING WU
?
Monitor is all for ops
Monitor is all for ops
琛琳 饶
?
Openstack nova
Openstack nova
Yong Luo
?
The Application of OpenStack in 360buy, by Bin He
The Application of OpenStack in 360buy, by Bin He
Hui Cheng
?
深入浅出Netty l.t
深入浅出Netty l.t
oleone
?
基于贵耻别濒的超融合一体机
基于贵耻别濒的超融合一体机
EdwardBadBoy
?
Using armeria to write your RPC
Using armeria to write your RPC
koji lin
?
Docker
Docker
旭 張
?
Traffic server overview
Traffic server overview
qianshi
?
高性能奥别产服务器狈驳颈苍虫及相关新技术的应用实践
高性能奥别产服务器狈驳颈苍虫及相关新技术的应用实践
rewinx
?
20081128 http caching_in_php
20081128 http caching_in_php
Hunter Wu
?
DAE
DAE
Qiangning Hong
?
顿辞耻产濒别叠颈苍濒辞驳方案
顿辞耻产濒别叠颈苍濒辞驳方案
Lixun Peng
?
Openstack neutron 原理详解
Openstack neutron 原理详解
Yong Luo
?
Oh K8s Is Swag - Kubernetes Basics
Oh K8s Is Swag - Kubernetes Basics
Okis Chuang
?
How to upgrade_ror3_to_ror4
How to upgrade_ror3_to_ror4
Wei-Yi Chiu
?
JCConf2015: groovy to gradle
JCConf2015: groovy to gradle
Ching Yi Chan
?
Ansible introduction
Ansible introduction
Chyi-Shian Jiang
?
Kafka cluster best practices
Kafka cluster best practices
Rico Chen
?
Monitor is all for ops
Monitor is all for ops
琛琳 饶
?
Openstack nova
Openstack nova
Yong Luo
?
The Application of OpenStack in 360buy, by Bin He
The Application of OpenStack in 360buy, by Bin He
Hui Cheng
?
深入浅出Netty l.t
深入浅出Netty l.t
oleone
?
基于贵耻别濒的超融合一体机
基于贵耻别濒的超融合一体机
EdwardBadBoy
?
Using armeria to write your RPC
Using armeria to write your RPC
koji lin
?
Traffic server overview
Traffic server overview
qianshi
?
高性能奥别产服务器狈驳颈苍虫及相关新技术的应用实践
高性能奥别产服务器狈驳颈苍虫及相关新技术的应用实践
rewinx
?
20081128 http caching_in_php
20081128 http caching_in_php
Hunter Wu
?
顿辞耻产濒别叠颈苍濒辞驳方案
顿辞耻产濒别叠颈苍濒辞驳方案
Lixun Peng
?
Openstack neutron 原理详解
Openstack neutron 原理详解
Yong Luo
?
Oh K8s Is Swag - Kubernetes Basics
Oh K8s Is Swag - Kubernetes Basics
Okis Chuang
?
How to upgrade_ror3_to_ror4
How to upgrade_ror3_to_ror4
Wei-Yi Chiu
?
JCConf2015: groovy to gradle
JCConf2015: groovy to gradle
Ching Yi Chan
?

More from StreamNative (20)

Is Using KoP (Kafka-on-Pulsar) a Good Idea? - Pulsar Summit SF 2022
Is Using KoP (Kafka-on-Pulsar) a Good Idea? - Pulsar Summit SF 2022
StreamNative
?
Building an Asynchronous Application Framework with Python and Pulsar - Pulsa...
Building an Asynchronous Application Framework with Python and Pulsar - Pulsa...
StreamNative
?
Blue-green deploys with Pulsar & Envoy in an event-driven microservice ecosys...
Blue-green deploys with Pulsar & Envoy in an event-driven microservice ecosys...
StreamNative
?
Distributed Database Design Decisions to Support High Performance Event Strea...
Distributed Database Design Decisions to Support High Performance Event Strea...
StreamNative
?
Simplify Pulsar Functions Development with SQL - Pulsar Summit SF 2022
Simplify Pulsar Functions Development with SQL - Pulsar Summit SF 2022
StreamNative
?
Towards a ZooKeeper-less Pulsar, etcd, etcd, etcd. - Pulsar Summit SF 2022
Towards a ZooKeeper-less Pulsar, etcd, etcd, etcd. - Pulsar Summit SF 2022
StreamNative
?
Validating Apache Pulsar’s Behavior under Failure Conditions - Pulsar Summit ...
Validating Apache Pulsar’s Behavior under Failure Conditions - Pulsar Summit ...
StreamNative
?
Cross the Streams! Creating Streaming Data Pipelines with Apache Flink + Apac...
Cross the Streams! Creating Streaming Data Pipelines with Apache Flink + Apac...
StreamNative
?
Message Redelivery: An Unexpected Journey - Pulsar Summit SF 2022
Message Redelivery: An Unexpected Journey - Pulsar Summit SF 2022
StreamNative
?
Unlocking the Power of Lakehouse Architectures with Apache Pulsar and Apache ...
Unlocking the Power of Lakehouse Architectures with Apache Pulsar and Apache ...
StreamNative
?
Understanding Broker Load Balancing - Pulsar Summit SF 2022
Understanding Broker Load Balancing - Pulsar Summit SF 2022
StreamNative
?
Building an Asynchronous Application Framework with Python and Pulsar - Pulsa...
Building an Asynchronous Application Framework with Python and Pulsar - Pulsa...
StreamNative
?
Pulsar's Journey in Yahoo!: On-prem, Cloud and Hybrid - Pulsar Summit SF 2022
Pulsar's Journey in Yahoo!: On-prem, Cloud and Hybrid - Pulsar Summit SF 2022
StreamNative
?
Event-Driven Applications Done Right - Pulsar Summit SF 2022
Event-Driven Applications Done Right - Pulsar Summit SF 2022
StreamNative
?
Pulsar @ Scale. 200M RPM and 1K instances - Pulsar Summit SF 2022
Pulsar @ Scale. 200M RPM and 1K instances - Pulsar Summit SF 2022
StreamNative
?
Data Democracy: Journey to User-Facing Analytics - Pulsar Summit SF 2022
Data Democracy: Journey to User-Facing Analytics - Pulsar Summit SF 2022
StreamNative
?
Beam + Pulsar: Powerful Stream Processing at Scale - Pulsar Summit SF 2022
Beam + Pulsar: Powerful Stream Processing at Scale - Pulsar Summit SF 2022
StreamNative
?
Welcome and Opening Remarks - Pulsar Summit SF 2022
Welcome and Opening Remarks - Pulsar Summit SF 2022
StreamNative
?
Log System As Backbone – How We Built the World’s Most Advanced Vector Databa...
Log System As Backbone – How We Built the World’s Most Advanced Vector Databa...
StreamNative
?
MoP(MQTT on Pulsar) - a Powerful Tool for Apache Pulsar in IoT - Pulsar Summi...
MoP(MQTT on Pulsar) - a Powerful Tool for Apache Pulsar in IoT - Pulsar Summi...
StreamNative
?
Is Using KoP (Kafka-on-Pulsar) a Good Idea? - Pulsar Summit SF 2022
Is Using KoP (Kafka-on-Pulsar) a Good Idea? - Pulsar Summit SF 2022
StreamNative
?
Building an Asynchronous Application Framework with Python and Pulsar - Pulsa...
Building an Asynchronous Application Framework with Python and Pulsar - Pulsa...
StreamNative
?
Blue-green deploys with Pulsar & Envoy in an event-driven microservice ecosys...
Blue-green deploys with Pulsar & Envoy in an event-driven microservice ecosys...
StreamNative
?
Distributed Database Design Decisions to Support High Performance Event Strea...
Distributed Database Design Decisions to Support High Performance Event Strea...
StreamNative
?
Simplify Pulsar Functions Development with SQL - Pulsar Summit SF 2022
Simplify Pulsar Functions Development with SQL - Pulsar Summit SF 2022
StreamNative
?
Towards a ZooKeeper-less Pulsar, etcd, etcd, etcd. - Pulsar Summit SF 2022
Towards a ZooKeeper-less Pulsar, etcd, etcd, etcd. - Pulsar Summit SF 2022
StreamNative
?
Validating Apache Pulsar’s Behavior under Failure Conditions - Pulsar Summit ...
Validating Apache Pulsar’s Behavior under Failure Conditions - Pulsar Summit ...
StreamNative
?
Cross the Streams! Creating Streaming Data Pipelines with Apache Flink + Apac...
Cross the Streams! Creating Streaming Data Pipelines with Apache Flink + Apac...
StreamNative
?
Message Redelivery: An Unexpected Journey - Pulsar Summit SF 2022
Message Redelivery: An Unexpected Journey - Pulsar Summit SF 2022
StreamNative
?
Unlocking the Power of Lakehouse Architectures with Apache Pulsar and Apache ...
Unlocking the Power of Lakehouse Architectures with Apache Pulsar and Apache ...
StreamNative
?
Understanding Broker Load Balancing - Pulsar Summit SF 2022
Understanding Broker Load Balancing - Pulsar Summit SF 2022
StreamNative
?
Building an Asynchronous Application Framework with Python and Pulsar - Pulsa...
Building an Asynchronous Application Framework with Python and Pulsar - Pulsa...
StreamNative
?
Pulsar's Journey in Yahoo!: On-prem, Cloud and Hybrid - Pulsar Summit SF 2022
Pulsar's Journey in Yahoo!: On-prem, Cloud and Hybrid - Pulsar Summit SF 2022
StreamNative
?
Event-Driven Applications Done Right - Pulsar Summit SF 2022
Event-Driven Applications Done Right - Pulsar Summit SF 2022
StreamNative
?
Pulsar @ Scale. 200M RPM and 1K instances - Pulsar Summit SF 2022
Pulsar @ Scale. 200M RPM and 1K instances - Pulsar Summit SF 2022
StreamNative
?
Data Democracy: Journey to User-Facing Analytics - Pulsar Summit SF 2022
Data Democracy: Journey to User-Facing Analytics - Pulsar Summit SF 2022
StreamNative
?
Beam + Pulsar: Powerful Stream Processing at Scale - Pulsar Summit SF 2022
Beam + Pulsar: Powerful Stream Processing at Scale - Pulsar Summit SF 2022
StreamNative
?
Welcome and Opening Remarks - Pulsar Summit SF 2022
Welcome and Opening Remarks - Pulsar Summit SF 2022
StreamNative
?
Log System As Backbone – How We Built the World’s Most Advanced Vector Databa...
Log System As Backbone – How We Built the World’s Most Advanced Vector Databa...
StreamNative
?
MoP(MQTT on Pulsar) - a Powerful Tool for Apache Pulsar in IoT - Pulsar Summi...
MoP(MQTT on Pulsar) - a Powerful Tool for Apache Pulsar in IoT - Pulsar Summi...
StreamNative
?
Ad

Serverless Event Streaming with Pulsar Functions-xiaolong