Apache Pulsar Cluster
Cloud-native distributed messaging and streaming platform with multi-tenancy.
Overview
Apache Pulsar is a cloud-native, distributed messaging and streaming platform originally developed by Yahoo and later open-sourced through the Apache Software Foundation. It provides unified queuing and streaming capabilities with multi-tenancy, geo-replication, and tiered storage support, making it a powerful alternative to traditional messaging systems like Apache Kafka and RabbitMQ. Pulsar's architecture separates serving from storage, enabling independent scaling and better resource utilization.
This deployment creates a complete Pulsar cluster with six interconnected services: a ZooKeeper instance for coordination, an initialization container for cluster metadata setup, two BookKeeper bookies (bookie1 and bookie2) for persistent message storage, a Pulsar broker for message routing and client connections, and Pulsar Manager for web-based administration. The setup demonstrates Pulsar's distributed architecture with proper separation of concerns between metadata management, storage, and serving layers.
This configuration is ideal for organizations evaluating Pulsar's capabilities, development teams building event-driven applications, and system architects requiring a messaging platform with strong multi-tenancy and geo-replication features. The cluster provides both the Pulsar binary protocol for high-performance messaging and HTTP admin APIs for management operations, making it suitable for both development and production evaluation scenarios.
Key Features
- Multi-tenant messaging with namespace isolation and resource quotas
- Unified publish-subscribe and message queuing in a single platform
- BookKeeper integration for durable message storage across multiple bookies
- Pulsar Manager web interface for cluster monitoring and administration
- Schema registry support for message schema evolution and validation
- Geo-replication capabilities for cross-region message distribution
- Tiered storage support for cost-effective long-term message retention
- Pulsar Functions framework for serverless stream processing
Common Use Cases
- 1Event-driven microservices architecture with guaranteed message delivery
- 2Real-time analytics pipelines requiring both streaming and queuing semantics
- 3Multi-tenant SaaS platforms needing isolated messaging per customer
- 4IoT data ingestion with high-throughput message processing requirements
- 5Financial services requiring exactly-once message delivery guarantees
- 6Content distribution networks with geo-replicated message flows
- 7Log aggregation and centralized logging infrastructure
Prerequisites
- Docker Engine 20.10+ and Docker Compose V2 for container orchestration
- Minimum 3GB RAM available for the cluster (ZooKeeper 256MB, bookies 512MB each, broker 512MB)
- Ports 6650 (Pulsar binary protocol), 8080 (admin API), 9527 and 7750 (Pulsar Manager) available
- Basic understanding of messaging concepts like topics, subscriptions, and producers/consumers
- Familiarity with BookKeeper storage concepts for message persistence configuration
- Knowledge of ZooKeeper for cluster metadata and coordination troubleshooting
For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms
docker-compose.yml
docker-compose.yml
1services: 2 zookeeper: 3 image: apachepulsar/pulsar:latest4 hostname: zookeeper5 command: bin/pulsar zookeeper6 environment: 7 - PULSAR_MEM=-Xms256m -Xmx256m8 volumes: 9 - zookeeper_data:/pulsar/data/zookeeper10 networks: 11 - pulsar-net12 restart: unless-stopped1314 init-cluster: 15 image: apachepulsar/pulsar:latest16 command: bin/pulsar initialize-cluster-metadata --cluster pulsar-cluster --zookeeper zookeeper:2181 --configuration-store zookeeper:2181 --web-service-url http://broker:8080 --broker-service-url pulsar://broker:665017 depends_on: 18 - zookeeper19 networks: 20 - pulsar-net2122 bookie1: 23 image: apachepulsar/pulsar:latest24 hostname: bookie125 command: bin/pulsar bookie26 environment: 27 - PULSAR_MEM=-Xms512m -Xmx512m28 - clusterName=pulsar-cluster29 volumes: 30 - bookie1_data:/pulsar/data/bookkeeper31 depends_on: 32 - zookeeper33 - init-cluster34 networks: 35 - pulsar-net36 restart: unless-stopped3738 bookie2: 39 image: apachepulsar/pulsar:latest40 hostname: bookie241 command: bin/pulsar bookie42 environment: 43 - PULSAR_MEM=-Xms512m -Xmx512m44 - clusterName=pulsar-cluster45 volumes: 46 - bookie2_data:/pulsar/data/bookkeeper47 depends_on: 48 - zookeeper49 - init-cluster50 networks: 51 - pulsar-net52 restart: unless-stopped5354 broker: 55 image: apachepulsar/pulsar:latest56 hostname: broker57 command: bin/pulsar broker58 ports: 59 - "6650:6650"60 - "8080:8080"61 environment: 62 - PULSAR_MEM=-Xms512m -Xmx512m63 - clusterName=pulsar-cluster64 - zookeeperServers=zookeeper:218165 - configurationStoreServers=zookeeper:218166 depends_on: 67 - bookie168 - bookie269 networks: 70 - pulsar-net71 restart: unless-stopped7273 pulsar-manager: 74 image: apachepulsar/pulsar-manager:latest75 ports: 76 - "9527:9527"77 - "7750:7750"78 environment: 79 SPRING_CONFIGURATION_FILE: /pulsar-manager/pulsar-manager/application.properties80 depends_on: 81 - broker82 networks: 83 - pulsar-net84 restart: unless-stopped8586volumes: 87 zookeeper_data: 88 bookie1_data: 89 bookie2_data: 9091networks: 92 pulsar-net: 93 driver: bridge.env Template
.env
1# Pulsar Configuration2PULSAR_CLUSTER_NAME=pulsar-cluster34# Pulsar Manager5PULSAR_MANAGER_ADMIN_USER=admin6PULSAR_MANAGER_ADMIN_PASSWORD=secure_manager_passwordUsage Notes
- 1Pulsar broker at pulsar://localhost:6650
- 2Admin API at http://localhost:8080
- 3Pulsar Manager at http://localhost:9527
- 4Initialize manager: curl -X PUT http://localhost:7750/pulsar-manager/users/superuser
Individual Services(6 services)
Copy individual services to mix and match with your existing compose files.
zookeeper
zookeeper:
image: apachepulsar/pulsar:latest
hostname: zookeeper
command: bin/pulsar zookeeper
environment:
- PULSAR_MEM=-Xms256m -Xmx256m
volumes:
- zookeeper_data:/pulsar/data/zookeeper
networks:
- pulsar-net
restart: unless-stopped
init-cluster
init-cluster:
image: apachepulsar/pulsar:latest
command: bin/pulsar initialize-cluster-metadata --cluster pulsar-cluster --zookeeper zookeeper:2181 --configuration-store zookeeper:2181 --web-service-url http://broker:8080 --broker-service-url pulsar://broker:6650
depends_on:
- zookeeper
networks:
- pulsar-net
bookie1
bookie1:
image: apachepulsar/pulsar:latest
hostname: bookie1
command: bin/pulsar bookie
environment:
- PULSAR_MEM=-Xms512m -Xmx512m
- clusterName=pulsar-cluster
volumes:
- bookie1_data:/pulsar/data/bookkeeper
depends_on:
- zookeeper
- init-cluster
networks:
- pulsar-net
restart: unless-stopped
bookie2
bookie2:
image: apachepulsar/pulsar:latest
hostname: bookie2
command: bin/pulsar bookie
environment:
- PULSAR_MEM=-Xms512m -Xmx512m
- clusterName=pulsar-cluster
volumes:
- bookie2_data:/pulsar/data/bookkeeper
depends_on:
- zookeeper
- init-cluster
networks:
- pulsar-net
restart: unless-stopped
broker
broker:
image: apachepulsar/pulsar:latest
hostname: broker
command: bin/pulsar broker
ports:
- "6650:6650"
- "8080:8080"
environment:
- PULSAR_MEM=-Xms512m -Xmx512m
- clusterName=pulsar-cluster
- zookeeperServers=zookeeper:2181
- configurationStoreServers=zookeeper:2181
depends_on:
- bookie1
- bookie2
networks:
- pulsar-net
restart: unless-stopped
pulsar-manager
pulsar-manager:
image: apachepulsar/pulsar-manager:latest
ports:
- "9527:9527"
- "7750:7750"
environment:
SPRING_CONFIGURATION_FILE: /pulsar-manager/pulsar-manager/application.properties
depends_on:
- broker
networks:
- pulsar-net
restart: unless-stopped
Quick Start
terminal
1# 1. Create the compose file2cat > docker-compose.yml << 'EOF'3services:4 zookeeper:5 image: apachepulsar/pulsar:latest6 hostname: zookeeper7 command: bin/pulsar zookeeper8 environment:9 - PULSAR_MEM=-Xms256m -Xmx256m10 volumes:11 - zookeeper_data:/pulsar/data/zookeeper12 networks:13 - pulsar-net14 restart: unless-stopped1516 init-cluster:17 image: apachepulsar/pulsar:latest18 command: bin/pulsar initialize-cluster-metadata --cluster pulsar-cluster --zookeeper zookeeper:2181 --configuration-store zookeeper:2181 --web-service-url http://broker:8080 --broker-service-url pulsar://broker:665019 depends_on:20 - zookeeper21 networks:22 - pulsar-net2324 bookie1:25 image: apachepulsar/pulsar:latest26 hostname: bookie127 command: bin/pulsar bookie28 environment:29 - PULSAR_MEM=-Xms512m -Xmx512m30 - clusterName=pulsar-cluster31 volumes:32 - bookie1_data:/pulsar/data/bookkeeper33 depends_on:34 - zookeeper35 - init-cluster36 networks:37 - pulsar-net38 restart: unless-stopped3940 bookie2:41 image: apachepulsar/pulsar:latest42 hostname: bookie243 command: bin/pulsar bookie44 environment:45 - PULSAR_MEM=-Xms512m -Xmx512m46 - clusterName=pulsar-cluster47 volumes:48 - bookie2_data:/pulsar/data/bookkeeper49 depends_on:50 - zookeeper51 - init-cluster52 networks:53 - pulsar-net54 restart: unless-stopped5556 broker:57 image: apachepulsar/pulsar:latest58 hostname: broker59 command: bin/pulsar broker60 ports:61 - "6650:6650"62 - "8080:8080"63 environment:64 - PULSAR_MEM=-Xms512m -Xmx512m65 - clusterName=pulsar-cluster66 - zookeeperServers=zookeeper:218167 - configurationStoreServers=zookeeper:218168 depends_on:69 - bookie170 - bookie271 networks:72 - pulsar-net73 restart: unless-stopped7475 pulsar-manager:76 image: apachepulsar/pulsar-manager:latest77 ports:78 - "9527:9527"79 - "7750:7750"80 environment:81 SPRING_CONFIGURATION_FILE: /pulsar-manager/pulsar-manager/application.properties82 depends_on:83 - broker84 networks:85 - pulsar-net86 restart: unless-stopped8788volumes:89 zookeeper_data:90 bookie1_data:91 bookie2_data:9293networks:94 pulsar-net:95 driver: bridge96EOF9798# 2. Create the .env file99cat > .env << 'EOF'100# Pulsar Configuration101PULSAR_CLUSTER_NAME=pulsar-cluster102103# Pulsar Manager104PULSAR_MANAGER_ADMIN_USER=admin105PULSAR_MANAGER_ADMIN_PASSWORD=secure_manager_password106EOF107108# 3. Start the services109docker compose up -d110111# 4. View logs112docker compose logs -fOne-Liner
Run this command to download and set up the recipe in one step:
terminal
1curl -fsSL https://docker.recipes/api/recipes/pulsar-cluster/run | bashTroubleshooting
- Broker fails to start with 'Unable to connect to zookeeper': Ensure ZooKeeper is fully started before broker initialization by checking container logs
- BookKeeper bookie registration errors: Verify the init-cluster container completed successfully and cluster metadata was properly initialized
- Pulsar Manager shows 'No clusters found': Use curl -X PUT http://localhost:7750/pulsar-manager/users/superuser to initialize the management interface
- Client connection refused on port 6650: Check that broker container is running and firewall allows connections to the Pulsar binary protocol port
- High memory usage warnings in logs: Adjust PULSAR_MEM environment variables for each service based on available system resources
- Topic creation fails with metadata errors: Restart the broker service after ensuring ZooKeeper and bookies are healthy and accessible
Community Notes
Loading...
Loading notes...
Download Recipe Kit
Get all files in a ready-to-deploy package
Includes docker-compose.yml, .env template, README, and license
Components
pulsar-brokerpulsar-bookiezookeeperpulsar-manager
Tags
#pulsar#messaging#streaming#multi-tenant#cloud-native
Category
Message Queues & BrokersAd Space
Shortcuts: C CopyF FavoriteD Download