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

Horizon Laravel Package

laravel/horizon

Laravel Horizon adds a beautiful dashboard and code-driven configuration for Laravel Redis queues. Monitor throughput, runtime, and failures, manage workers and supervisors from a single config file, and keep queue operations visible and maintainable.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Queue Management: Horizon is a first-class solution for Laravel’s Redis-based queues, offering a dashboard, monitoring, and configuration layer atop Laravel’s built-in queue system. It aligns perfectly with Laravel’s event-driven architecture and asynchronous task processing needs.
  • Separation of Concerns: The package enforces code-driven configuration (via config/horizon.php), enabling team collaboration and version-controlled queue management.
  • Extensibility: Supports custom job monitoring, batch processing, and Redis Cluster (v5.46.0+), making it adaptable to scalable, high-throughput systems.
  • Laravel Ecosystem Lock-in: Tightly integrated with Laravel’s queue workers, jobs, and events, reducing friction for teams already using Laravel.

Integration Feasibility

  • Prerequisites:
    • Redis (required for queue storage; Horizon adds monitoring layers).
    • Laravel 10+ (official support; v5.44.0+ explicitly supports Laravel 13).
    • PHP 8.1+ (minimum; v5.40.1+ adds PHP 8.5 compatibility).
  • Compatibility:
    • Works seamlessly with Laravel’s queue drivers (Redis, database, etc.), but optimized for Redis (recommended for production).
    • Supports custom queue connections (e.g., redis:cluster for scaling).
    • No breaking changes in recent versions (backward-compatible with Laravel 9+).
  • Dependencies:
    • Lightweight core (no heavy frameworks; uses Vite for frontend, Laravel’s Redis client).
    • No external services required (self-hosted dashboard).

Technical Risk

Risk Area Assessment Mitigation Strategy
Redis Dependency Critical for functionality; downtime = queue paralysis. Implement Redis HA (sentinel/cluster) and fallback queue drivers (e.g., database).
Dashboard Overhead Frontend (Vite) adds ~500KB JS; may impact cold starts. Lazy-load Horizon dashboard in non-critical paths; use server-side rendering for metrics.
Job Monitoring Gaps Limited visibility into third-party jobs (non-Laravel classes). Extend Horizon’s JobProcessor or use custom middleware for instrumentation.
Scaling Limits Single Redis instance may bottleneck under high throughput. Deploy Redis Cluster (supported since v5.46.0) or shard queues by connection.
Legacy Laravel Older Laravel versions (<10) may lack full feature parity. Test on Laravel 10+; use composer platform checks to enforce compatibility.

Key Questions for TPM

  1. Queue Workload Profile:
    • What’s the expected job volume (e.g., 1000/jour vs. 1M/jour)?
    • Are there spiky loads (e.g., cron triggers) or steady-state processing?
  2. Observability Needs:
    • Beyond Horizon’s dashboard, do you need custom metrics (e.g., Prometheus) or alerting (e.g., Slack)?
    • Are failed job retries a critical path (Horizon supports backoff strategies).
  3. Deployment Constraints:
    • Can Redis run in-cluster (for HA) or is single-node acceptable?
    • Are there security restrictions (e.g., no public dashboard; use private tunnels via Horizon’s local env support).
  4. Team Maturity:
    • Does the team have Laravel queue experience? Horizon assumes familiarity with dispatch(), jobs, and workers.
    • Is configuration-as-code (vs. manual dashboard tweaks) a priority?

Integration Approach

Stack Fit

  • Core Stack:
    • Backend: Laravel 10/11/13 (Horizon is first-party for these).
    • Queue Driver: Redis (recommended; Horizon adds monitoring layers).
    • Frontend: Optional dashboard (Vite-based; can be disabled for CLI-only use).
    • Infrastructure: Supports Docker, Kubernetes, and serverless (e.g., Laravel Vapor with Redis).
  • Alternatives Considered:
    • RabbitMQ/SQS: Better for distributed systems but lack Laravel’s tight integration.
    • Sidekiq: Ruby-focused; Horizon is PHP-native with Laravel’s event system.
    • Custom Solutions: Higher maintenance; Horizon provides batteries-included monitoring.

Migration Path

Step Action Tools/Commands
1. Prereq Check Verify Redis and Laravel compatibility (PHP 8.1+, Laravel 10+). composer require laravel/horizon + php artisan horizon:install
2. Config Define queue workers in config/horizon.php (e.g., supervisors, connections). Edit config/horizon.php; use php artisan horizon:configure.
3. Dashboard Publish Horizon’s assets (optional; disable with --no-dashboard). php artisan horizon:publish --tag=config + npm install && npm run dev.
4. Test Validate with horizon:listen (CLI) or horizon:work (dashboard). php artisan horizon:listen --supervisor=supervisor-name.
5. Monitor Set up health checks and alerts (e.g., failed jobs > X). Use Horizon’s failed jobs table + external tools (e.g., Datadog).
6. Scale Add Redis Cluster or shard queues by connection. Update config/horizon.php with redis:cluster connection.

Compatibility

  • Laravel Versions:
    • Fully Supported: 10.x, 11.x, 13.x.
    • Legacy: 9.x (tested but may miss v5.44.0+ features).
  • Queue Drivers:
    • Primary: Redis (optimized for Horizon).
    • Secondary: Database (limited monitoring; no dashboard features).
  • Third-Party Jobs:
    • Horizon only monitors Laravel jobs by default. Custom instrumentation needed for:
      • Non-Laravel classes (e.g., App\Jobs\SendEmail works; Vendor\Lib\Task may not).
      • Workaround: Extend Horizon\JobProcessor or use tags to categorize jobs.

Sequencing

  1. Phase 1: Pilot
    • Deploy Horizon to a non-production queue (e.g., emails).
    • Validate dashboard metrics and failed job handling.
  2. Phase 2: Core Queues
    • Migrate high-priority queues (e.g., payments, notifications).
    • Configure alerts for failures (e.g., Slack via Laravel Notifications).
  3. Phase 3: Optimization
    • Tune worker processes (supervisors in horizon.php).
    • Implement Redis Cluster if scaling beyond single-node.
  4. Phase 4: Observability
    • Integrate with Prometheus/Grafana for long-term metrics.
    • Archive failed jobs to a database for auditing.

Operational Impact

Maintenance

  • Pros:
    • Centralized config: All queue settings in config/horizon.php (version-controlled).
    • Automated updates: Laravel’s package auto-update (via composer) for security patches.
    • Low operational overhead: Dashboard self-hosted; no SaaS dependencies.
  • Cons:
    • Redis maintenance: Horizon does not manage Redis; teams must handle:
      • Backups, scaling, and failover (use Redis Sentinel/Cluster).
    • Dashboard updates: Frontend (Vite) may require npm run dev after Laravel updates.
  • Tooling:
    • CLI Commands:
      • horizon:terminate (graceful shutdown).
      • horizon:flush (clear queues; use cautiously).
      • horizon:retry (requeue failed jobs).
    • Supervisor Integration: Works with Laravel Forge, Envoyer, and Docker.

Support

  • Troubleshooting:
    • Common Issues:
      • Redis connection errors: Check config/horizon.php and Redis server status.
      • Dashboard not loading: Verify Vite assets (npm run dev) and storage/framework/views permissions.
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.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony