Skip to content

leocavalcante/kafka-phplayground

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kafka PHPlayground

🎸 Just some fun with Kafka, PHP and Swoole.

Apache Kafka is an open-source distributed event streaming platform used by thousands of companies for high-performance data pipelines, streaming analytics, data integration, and mission-critical applications.

Swoole is a Coroutine based Async PHP Programming Framework to Build high-performance, scalable, concurrent TCP, UDP, Unix Socket, HTTP, WebSocket services with PHP and fluent Coroutine API.

Requirements

Instructions

Kafka

Start the services

  • kafka/bin/zookeeper-server-start.sh kafka/config/zookeeper.properties
  • kafka/bin/kafka-server-start.sh kafka/config/server.properties

Create a topic

  • kafka/bin/kafka-topics.sh --create --topic my-topic --bootstrap-server localhost:9092
    • Created topic my-topic. should be the response

PHP

If you don't have Swoole already:

  • pecl install swoole

Install dependencies

Mainly https://github.com/easy-swoole/kafka

  • composer install

Start the consumer

  • php consumer.php

Let's play!

Write some events

  • kafka/bin/kafka-console-producer.sh --topic my-topic --bootstrap-server localhost:9092

Then just type some messages to the stdin. Press Ctrl+C to stop.

Screenshot 01

A PHP producer

Just checkout producer.php.

Screenshot 02

Let's Rock

Easy

Screenshot 03

Screenshot 04

Medium

Screenshot 05

Hard

Screenshot 06

âš  Actually, I'm not sure if this is rocking. If you have a proper way to benchmark a consumer, please issue me.

About

🎸 Just some fun with Kafka, PHP and Swoole

Topics

Resources

License

Stars

Watchers

Forks

Languages