Apache Kafka with PHP
Stream high-throughput events using Kafka.
Kafka with PHP
Kafka is not a task queue — it is a distributed, append-only commit log. Producers append records to topics; consumers read at their own offset and can replay history. This makes Kafka ideal for high-throughput event streams, event sourcing, and feeding multiple independent consumer groups from one stream.
In PHP you talk to Kafka through ext-rdkafka, a binding over the battle-tested C library librdkafka.
Log, Not Queue
The mental shift from RabbitMQ to Kafka:
- Messages are not deleted when consumed; they expire by retention policy (time or size).
- Each consumer tracks its own offset — its position in the log.
- A topic is split into partitions; ordering is guaranteed only within a partition.
- Multiple consumer groups read the same topic independently.
If you need replay, fan-out to many readers, or massive throughput, Kafka fits. If you need per-message routing and TTLs, RabbitMQ fits.