Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Rdkafka Laravel Package

enqueue/rdkafka

Kafka transport for Enqueue using the RdKafka (librdkafka) extension. Implements Queue Interop so you can produce and consume messages via Kafka with Enqueue tooling. Links to docs, support channels, and issue tracker.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Event-Driven Architecture (EDA) Adoption: Enables seamless integration of Kafka as a message broker for Laravel applications, aligning with modern microservices and distributed systems architectures. Supports use cases like real-time notifications, event sourcing, and CQRS patterns.
  • Scalability & Performance: Ideal for high-throughput applications (e.g., IoT, financial systems, or high-traffic web apps) requiring low-latency, distributed messaging. Kafka’s horizontal scaling and partition-based throughput address bottlenecks in traditional queue systems.
  • Decoupling & Resilience: Facilitates loose coupling between services by leveraging Kafka’s pub/sub model, enabling independent scaling and fault isolation. Reduces cascading failures in monolithic Laravel applications.
  • Hybrid Queue Strategy: Allows mixing Kafka with other Enqueue transports (e.g., Redis for local jobs, RabbitMQ for legacy systems) for failover, workload distribution, or gradual migration.
  • Roadmap for Real-Time Features: Future-proofs the application for real-time analytics, event-driven workflows, or reactive programming without vendor lock-in. Aligns with Laravel’s growing adoption of async/await and event systems.
  • Build vs. Buy: Avoids reinventing Kafka integration from scratch, reducing development time and maintenance overhead. Leverages the Queue Interop standard to ensure interoperability with other PHP queue systems.
  • Cost Optimization: Reduces operational costs by reusing existing Kafka infrastructure (e.g., self-hosted clusters or managed services like Confluent Cloud) and eliminating proprietary queue solutions.

When to Consider This Package

Adopt If:

  • Kafka is Already in Your Stack: You’re using Kafka for other purposes (e.g., data pipelines, real-time analytics) and want to standardize messaging across the Laravel app.
  • High Throughput or Durability Needs: Your application processes thousands of messages per second or requires exactly-once processing, message retention, or replayability (e.g., audit logs, financial transactions).
  • Event-Driven or Microservices Architecture: You’re building a distributed system where services communicate via events (e.g., domain events, user actions) and need decoupled, scalable consumers.
  • Queue Interop Compatibility: Your Laravel app already uses Enqueue (or Symfony Messenger) and you want to standardize on Kafka without rewriting job consumers.
  • Hybrid Queue Requirements: You need to mix Kafka with other transports (e.g., Redis for local jobs, RabbitMQ for legacy systems) for failover or workload balancing.

Avoid If:

  • Low-Volume or Simple Workloads: For basic cron jobs, notifications, or low-throughput tasks, Laravel’s native queue (database/Redis) or a simpler broker like RabbitMQ is sufficient.
  • Lack of Kafka Expertise: Your team lacks experience with Kafka’s consumer groups, offset management, or cluster operations, which adds operational complexity.
  • Strict Priority-Based Processing: Kafka lacks built-in priority queues. Use Redis (with sorted sets) or RabbitMQ (with priority queues) instead.
  • Tight Budget for DevOps: Kafka requires cluster management, monitoring, and scaling expertise, which may not fit small teams or cost-sensitive projects.
  • Legacy Laravel Monolith: If your app is a single-service monolith with no plans for microservices, the overhead of Kafka may not justify the benefits.

How to Pitch It (Stakeholders)

For Executives:

*"This package lets us leverage Kafka—our existing high-performance message broker—to power Laravel’s background jobs, real-time notifications, and event-driven workflows. By adopting enqueue/rdkafka, we unlock:

  • Scalability at Scale: Handle millions of messages per second with Kafka’s distributed architecture, eliminating bottlenecks in high-traffic features (e.g., user notifications, IoT data processing).
  • Cost Efficiency: Reuse our existing Kafka infrastructure (or switch to a managed service like Confluent Cloud) without building custom integrations.
  • Future-Proof Architecture: Align with our microservices roadmap and real-time data needs (e.g., analytics, event sourcing) while avoiding vendor lock-in.
  • Resilience: Decouple services with Kafka’s pub/sub model, reducing cascading failures and improving fault tolerance.
  • Minimal Investment: Open-source (MIT license), well-documented, and integrates seamlessly with Laravel’s queue system. No upfront dev costs; ROI comes from faster development and lower operational overhead.

Example Use Cases:

  • Replace Redis queues for high-volume background jobs (e.g., video encoding, batch processing).
  • Enable real-time user activity feeds via Kafka topics.
  • Decouple payment processing from the web app for better scalability.

Next Steps: Pilot with a non-critical workflow (e.g., analytics processing) to validate performance and operational impact."*


For Engineering:

*"This is a drop-in Kafka transport for Enqueue, letting us replace or extend Laravel’s queue system with Kafka’s power—without rewriting consumers. Here’s how it fits:

  • Replace Redis/RabbitMQ Queues: Swap out simple brokers for Kafka’s high-throughput, durable messaging for critical workloads.
  • Leverage Kafka’s Strengths:
    • Exactly-once processing (no duplicates/misses).
    • Consumer groups for horizontal scaling.
    • Message retention and replayability (e.g., for debugging or audits).
  • Integrate with Existing Tools:
    • Works with Laravel’s dispatch() and Queue facade.
    • Compatible with Symfony Messenger or raw PHP consumers.
  • Hybrid Flexibility: Use Enqueue’s Context to route messages between Kafka and other transports (e.g., Redis for local jobs).

Trade-offs:

  • Complexity: Requires Kafka cluster setup (but we can reuse existing infra) and understanding of consumer groups and offset commits.
  • Dependencies: Needs librdkafka (C extension) and PHP’s ext-kafka (or Docker to abstract this).
  • Monitoring Gaps: No built-in Laravel Scout/Horizon integration for Kafka metrics (e.g., lag, throughput).

Next Steps:

  1. Benchmark: Compare Kafka vs. current queues for a sample workload (e.g., 10K jobs/sec).
  2. Pilot: Replace a non-critical queue (e.g., notifications) with Kafka to test integration.
  3. Plan Migration: Start with hybrid setups (e.g., Kafka for distributed jobs, Redis for local) before full adoption.

Example Code Snippet:

// config/queue.php
'connections' => [
    'kafka' => [
        'driver' => 'kafka',
        'hosts' => env('KAFKA_HOSTS', 'kafka:9092'),
        'topic' => 'laravel-jobs',
        'group_id' => 'laravel-consumers',
    ],
],

// Dispatch a job
dispatch(new ProcessPodcast)->onConnection('kafka');

// Consumer setup
$consumer = new \Enqueue\Kafka\KafkaConsumer($producer, [
    'group.id' => 'laravel-group',
]);
$consumer->consume(function ($message) {
    dispatch(new HandleJob($message->getBody()));
});
```"

---
**Key Asks for Stakeholders**:
- **Executives**: Approval to pilot with a non-critical workflow and allocate Kafka cluster resources.
- **DevOps**: Confirmation that Kafka infrastructure (or managed service) is available and configured for Laravel’s needs.
- **Engineering**: Bandwidth to upskill on Kafka’s consumer groups and offset management.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
croct/coding-standard
croct/plug-php
nqxcode/phpmorphy
boundwize/pyrameter
testo/facade
develia/commons
dmstr/symfony-system-resources-bundle
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
renatomarinho/laravel-page-speed
develia/geo-bundle
austinheap/laravel-database-encryption
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
imbo/imbo-coding-standard
visualbuilder/filament-lottie
servicioslineaonce/starter-kit
atomcoder/laravel-reorderable
irajul/filament-shadcn-theme