- How do I set up Gearman as a Laravel queue driver?
- Add the `enqueue/laravel` bridge and register the Gearman transport in `config/queue.php` under a custom connection (e.g., `'gearman'`). Configure the host, port, and timeout, then dispatch jobs using Laravel’s `dispatch()` or `queue:work` commands. Note: Workers must be managed externally (e.g., CLI scripts or Docker).
- Does enqueue/gearman support Laravel’s Queue::later() for delayed jobs?
- No, Gearman lacks native delayed job support. Use Enqueue’s delay extension or implement custom logic (e.g., storing timestamps in job metadata) to simulate delays. For production, consider alternatives like Redis or RabbitMQ if delayed jobs are critical.
- What Laravel versions are compatible with enqueue/gearman?
- The package works with Laravel 5.5+ via the `enqueue/laravel` bridge, which abstracts Laravel’s queue system. However, since `enqueue/gearman` itself is outdated (last updated 2017), test thoroughly for compatibility, especially with newer Laravel features like job middleware or events.
- How do I deploy Gearman workers for Laravel jobs?
- Gearman workers are external processes—deploy them via Docker containers, Kubernetes StatefulSets, or CLI scripts. Use a script to load your job handlers (e.g., `require __DIR__.'/bootstrap/app.php'; $worker->handleJob()`) and point them to the Gearman server. Monitor workers separately from Laravel’s queue workers.
- Are there alternatives to Gearman for Laravel async jobs?
- Yes. For modern Laravel apps, consider `enqueue/redis` (high performance, supports delays), `enqueue/rabbitmq` (enterprise-grade), or Laravel’s built-in database queue. Gearman is only suitable if you’re tied to existing Gearman infrastructure or need its RPC-style workflows.
- How do I handle job failures or retries with Gearman in Laravel?
- Gearman lacks built-in retry logic. Use Laravel’s `FailedJob` events to log failures, then implement custom retry logic (e.g., requeue jobs with a delay). For dead-letter queues, store failed jobs in a database table and process them manually. Monitor Gearman workers for crashes.
- Can I use enqueue/gearman in production without forking the package?
- Proceed with caution. The package is unmaintained (last update: 2017), so security or compatibility risks may arise. Mitigate by: 1) isolating Gearman workers, 2) monitoring for failures, and 3) having a fallback queue (e.g., database). If critical, fork and maintain it yourself.
- How does Gearman’s performance compare to Redis or RabbitMQ for Laravel?
- Gearman is generally slower than Redis (in-memory) or RabbitMQ (optimized for messaging). Benchmark with your workload: Gearman’s RPC model adds overhead, while Redis offers sub-millisecond latency. Use Gearman only if you’re constrained by legacy systems or need its distributed task execution.
- Do I need to install a Gearman server separately for Laravel?
- Yes. The `enqueue/gearman` package requires a running `gearmand` server (not included). Install it via your OS package manager (e.g., `apt-get install gearman` on Ubuntu) or Docker. Laravel’s queue system won’t manage the Gearman server—you’re responsible for its uptime and scaling.
- How can I monitor Gearman workers and job status in Laravel?
- Gearman lacks native observability. Integrate with Laravel’s `FailedJob` events for visibility into failures, and use external tools like Prometheus to scrape Gearman metrics (e.g., worker CPU/memory). For job tracking, log payloads to a database or use Enqueue’s context objects to attach metadata.