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

Php Resque Laravel Package

catch-of-the-day/php-resque

Redis-backed background job queue for PHP (Resque port). Enqueue jobs onto one or more prioritized queues and process them with distributed workers. Supports forking for leak resilience, failure handling, optional job status tracking, and setUp/tearDown hooks.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Redis-backed job queue: Aligns well with Laravel’s existing Redis integration (e.g., caching, sessions, queues). Leverages Redis for persistence, scalability, and atomic operations.
  • Event-driven hooks: Complements Laravel’s event system, enabling customization of job lifecycle (e.g., logging, retries, monitoring).
  • Priority queues: Supports Laravel’s queue prioritization needs (e.g., critical vs. low-priority jobs).
  • Forking model: Mimics Ruby’s Resque but introduces PHP-specific quirks (e.g., child process cleanup). May conflict with Laravel’s single-process PHP-FPM/CLI model unless managed carefully.

Integration Feasibility

  • Laravel Queue Contract Compliance: Does not natively integrate with Laravel’s Illuminate\Queue contract, requiring a wrapper layer or custom queue driver.
  • Job Serialization: Uses PHP’s native serialize() for job payloads, which may cause issues with complex objects (e.g., closures, resources). Laravel’s Illuminate\Contracts\Queue\ShouldBeQueued expects JSON-serializable payloads by default.
  • Worker Management: Laravel’s queue workers (php artisan queue:work) are incompatible with php-resque’s fork-based model. Requires custom CLI scripts or process managers (e.g., Supervisor).
  • Monitoring: Lacks a built-in web UI (unlike Laravel Horizon). Would need integration with tools like Laravel Telescope or custom Redis monitoring.

Technical Risk

  • PHP 5.3+ Dependency: Laravel 9+ requires PHP 8.0+. While php-resque works, some features (e.g., process titles) rely on PECL extensions or PHP 5.5+.
  • Memory Leaks: Forking workers in PHP can lead to memory bloat if not managed (e.g., no shared memory between forks). Laravel’s queue workers use a single process, avoiding this.
  • Error Handling: Jobs failing silently (e.g., unhandled exceptions) may require custom onFailure hooks to mirror Laravel’s retry/fail mechanisms.
  • Redis Schema: Uses a custom Redis key prefix (PREFIX env var). Must align with Laravel’s existing Redis keys (e.g., laravel:queue:failed) to avoid collisions.
  • Testing: Minimal test coverage and no Laravel-specific tests. Risk of edge cases (e.g., job timeouts, Redis connection drops).

Key Questions

  1. Why not Laravel’s Native Queues?

    • Does php-resque offer unique features (e.g., setUp/tearDown, fine-grained job status tracking) not available in Laravel’s database/redis drivers?
    • Is Redis performance a bottleneck for Laravel’s default drivers?
  2. Worker Lifecycle Management

    • How will workers be deployed? Supervisor scripts? Laravel’s queue:work?
    • How will job failures be handled (e.g., retries, dead-letter queues)?
  3. Compatibility with Laravel Ecosystem

    • Can php-resque jobs be triggered via Laravel’s dispatch() or dispatchSync()?
    • How will job payloads (e.g., ShouldBeQueued objects) be serialized/deserialized?
  4. Monitoring and Observability

    • How will job statuses (e.g., STATUS_WAITING, STATUS_FAILED) be surfaced to Laravel’s monitoring tools (e.g., Horizon, Telescope)?
    • Are there plans to build a Laravel-specific queue driver wrapper?
  5. Scaling and Concurrency

    • How will multiple workers be coordinated (e.g., avoiding duplicate jobs)?
    • What’s the impact of Redis connection pooling on performance?

Integration Approach

Stack Fit

  • Laravel + Redis: High fit due to shared Redis backend and Laravel’s existing Redis abstractions.
  • PHP 8.0+: Requires polyfills or PECL extensions (e.g., proctitle) for full feature parity.
  • Process Management: Needs integration with:
    • Supervisor (for long-running workers).
    • Laravel’s queue:work (via custom queue driver or wrapper).
    • Docker/Kubernetes (if orchestrating workers in containers).

Migration Path

  1. Phase 1: Proof of Concept

    • Implement a minimal php-resque queue driver for Laravel (extending Illuminate\Queue\RedisQueue).
    • Test job enqueuing/dequeuing with simple jobs (e.g., SendEmailJob).
    • Validate serialization/deserialization of Laravel payloads.
  2. Phase 2: Worker Integration

    • Replace Laravel’s queue:work with custom php-resque scripts (e.g., bin/resque).
    • Configure Supervisor to manage workers (e.g., restart on crash, concurrency limits).
    • Implement job failure handling (e.g., onFailure hooks to log to Laravel’s failed_jobs table).
  3. Phase 3: Feature Parity

    • Add Laravel-specific hooks (e.g., integrate with Illuminate\Queue\Events\JobProcessed).
    • Build a Horizon-compatible monitoring layer (e.g., expose job statuses via Redis).
    • Implement priority queues (if not already supported by Laravel’s Redis driver).
  4. Phase 4: Optimization

    • Benchmark performance against Laravel’s native Redis driver.
    • Optimize Redis key prefixes to avoid collisions with Laravel’s caching/sessions.
    • Add support for Laravel’s queue middleware (e.g., RetryAfterFailedJobs).

Compatibility

Feature Laravel Native Queues php-resque Integration Notes
Job Serialization JSON PHP serialize() Risk: Complex objects may fail.
Retry Mechanism Built-in Manual Requires onFailure hooks.
Delayed Jobs Supported Not documented May need custom implementation.
Middleware Supported No Would require wrapper layer.
Horizon Monitoring Native No Custom UI or Redis scraping needed.
Forking Model Single-process Multi-fork Supervisor required for stability.

Sequencing

  1. Start with a Single Queue

    • Migrate one non-critical queue (e.g., emails) to php-resque.
    • Monitor Redis memory usage and worker stability.
  2. Add Critical Path Jobs Gradually

    • Prioritize queues with high failure rates or long runtime (e.g., report-generators).
  3. Implement Observability Early

    • Log job statuses to Laravel’s failed_jobs table via onFailure hooks.
    • Expose Redis metrics to Prometheus/Grafana.
  4. Phase Out Native Drivers

    • Once stable, replace all queue drivers with php-resque wrapper.

Operational Impact

Maintenance

  • Dependencies:
    • Redis 2.2+ (Laravel already requires this).
    • PHP 5.3+ (but Laravel 9+ needs 8.0+; may require PHP polyfills).
    • PECL extensions (e.g., proctitle) for process titles.
  • Updates:
    • php-resque is unmaintained (last commit ~2015). Fork or maintain a patched version.
    • Laravel’s Redis driver may evolve; ensure compatibility.
  • Debugging:
    • Worker logs (VERBOSE, VVERBOSE) may not integrate with Laravel’s log channels. Redirect to storage/logs/resque.log.
    • Job failures require custom error handling (e.g., onFailure hooks to trigger Laravel’s failed event).

Support

  • Lack of Community:
    • No Laravel-specific support. Issues must be resolved via Ruby Resque docs or community forums.
  • Tooling Gaps:
    • No Horizon integration → manual monitoring or custom scripts.
    • No built-in retry logic → must implement via hooks or middleware.
  • Fallback Plan:
    • Document rollback to Laravel’s native Redis driver.
    • Use feature flags to toggle between queue drivers.

Scaling

  • Horizontal Scaling:
    • Workers scale by adding more processes (managed via Supervisor).
    • Redis cluster support is theoretical (not tested in php-resque).
  • Vertical Scaling:
    • Memory usage per worker is limited by PHP’s memory_limit (forking may exacerbate leaks).
    • Consider reducing COUNT env var if jobs are memory-intensive.
  • Performance Bottlenecks:
    • Redis connection pooling is manual (Laravel’s Predis handles this automatically).
    • Job serialization/deserialization may be slower than Laravel’s JSON approach.

Failure Modes

Scenario Impact Mitigation Strategy
Redis connection drops Jobs stuck in queue Implement exponential backoff in workers.
Worker crashes Unprocessed jobs Supervisor auto-restart + dead-letter queue.
Job timeouts Failed jobs Set timeout in job class or worker config.
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.
nasirkhan/laravel-sharekit
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony