Apache Pulsar — Gentle Introduction
Apache Pulsar, it is a pub-sub messaging platform backed by durable storage (uses Apache Bookkeeper), with the following cool features:
- Zero Data Loss
- Zero Rebalancing time
- Unified Queuing and Streaming Model
- Highly Scalable
- High Throughput
- Pulsar Proxy
Pulsar documentation explains every feature in detail. Blog is from the customer perspective of using Pulsar.
Pulsar has a layered architecture which isolates the storage mechanism from broker. This architecture provides me the following benefits of:
- Scale Brokers independently
- Scale Bookies independently
- Containerize the Zookeeper, Broker and Bookies.
- Zookeeper provides the configuration and state of the cluster.
Below are the highlights from the above diagram which excites us to choose Pulsar:
- Load Balancer : Pulsar has inbuilt load balancer which distributes load across all brokers internally.
- Service Discovery : Pulsar has inbuilt service discovery to identify where and how to connect to the brokers using single endpoint.
- Global Replicators : Helps in replicating the data between n-brokers as configured for the namespace.
- Global ZK : Global Zookeeper helps in enablement of geo-replication.
Geo-replication is out of the box solution in pulsar. Global clusters can be configured at namespace level to get it replicated within any number of clusters (n-way mesh solution). From the below example, datacenter C does not have a Consumer, but still message is consumed in datacenter A or B based on the subscription model.
Within an organization, multi-tenancy feature helps to standup one cluster for an enterprise by still providing isolation to data storage. This builtin feature will drastically bring down the infrastructure and operational cost to the organization.
** I am planning to publish a detailed blog on establishing this feature in Pulsar.
Zero Rebalancing Time
Pulsar’s layered architecture and broker’s stateless nature helps with zero rebalancing time. If a new broker is added to the cluster, it immediately available for writes and reads; does not spend anytime in rebalancing data across the cluster.
From the perspective of Bookies: when a new bookie is added to the cluster; it immediately ready for any writes due to its underlying Distributed Log Architecture — Read/Write Isolation. Rebalancing of the data based on the segment replication configuration will takes place behind the scenes without any impact for being in cluster.
Unified Queuing and Streaming Model
Pulsar supports both streaming and queuing semantic in one model. This feature can be achieved through Subscription Model. Consumers subscribe to the topic using any one of the subscription model:
- Exclusive — Supports streaming semantic
- Failover — Supports streaming semantic
- Shared — Supports queuing semantic
Functions are the localized listeners which can live within or outside of pulsar. From the usage per se, Functions can be used for content based routing which will help the enterprise applications to receive only/all the intended messages.
Proxy are needed to expose the brokers to outside world when deployed in cloud or Kubernetes. Proxy by itself can provide Authentication and Authorization and seamlessly connect with broker on TLS or without TLS. Proxy has a inbuilt feature to pass authorization token to broker for namespace permission validation.
Apache Pulsar is a powerful pub-sub model built on layered architecture which comes out of the box with Geo-Replication, Multi-Tenant, Zero Rebalancing time, Unified Queuing &Streaming, TLS based Authentication/Authorization, Proxy and Durability.
Happy Pulsaring !