How to Scale a Laravel SaaS App with Octane and Horizon
Learn how Laravel Octane and Horizon help scale SaaS applications by improving response times, optimizing queues, and supporting high-traffic Laravel workloads.
How to Scale a Laravel SaaS App with Octane and Horizon
Scaling a Laravel SaaS application is one of the most consequential technical decisions a product team will face. The architecture choices made at 1,000 users tend to crack under the pressure of 100,000. Response times creep upward, queues back up, and what once felt like a solid foundation starts to feel more like a liability.
The good news: Laravel's modern tooling—specifically Octane and Horizon—provides a clear, structured path for teams that want to scale without rebuilding from scratch. This guide covers the core concepts, configuration strategies, and deployment patterns that keep SaaS applications performant under real-world load.
Understanding the Performance Bottlenecks in Laravel SaaS Applications
Before configuring tools, it helps to understand where Laravel applications typically slow down at scale.
The traditional PHP request lifecycle is stateless by design. Every incoming request bootstraps the entire application—loading service providers, resolving bindings, and establishing database connections—before executing a single line of business logic. At low traffic, this overhead is negligible. At high traffic, it becomes a measurable drag on response times and infrastructure costs.
Queue throughput presents a separate challenge. As SaaS applications grow, background jobs multiply: emails, notifications, report generation, webhook deliveries. A single-worker setup that handled early-stage load will stall as job volume increases, leading to delayed processing and frustrated users.
These two problems—slow HTTP responses and queue congestion—are precisely what Octane and Horizon are designed to address.
What Is Laravel Octane?
Laravel Octane supercharges your application's performance by keeping it resident in memory between requests. Rather than bootstrapping the framework on every hit, Octane boots Laravel once and serves subsequent requests from that warm state.
Under the hood, Octane supports two high-performance application servers: Swoole and RoadRunner. Both eliminate the per-request bootstrapping overhead, with Swoole additionally enabling coroutine-based concurrency for I/O-bound operations.
Setting Up Laravel Octane
Installation is straightforward via Composer:
composer require laravel/octane php artisan octane:install
During installation, you will be prompted to choose between Swoole and RoadRunner. Swoole is the recommended choice for most SaaS workloads due to its mature concurrency model and built-in support for coroutines, timers, and WebSockets.
To start the Octane server locally:
php artisan octane:start --workers=4 --task-workers=2
The --workers flag controls the number of concurrent request workers. A sensible starting point is one worker per CPU core, adjusted based on profiling results.
Critical Octane Configuration Considerations
Octane's memory-resident architecture introduces an important constraint: state must not leak between requests. Static properties, singleton instances that mutate during a request, and class-level caches can all persist across requests if not properly managed.
To mitigate this, use the octane.php configuration file to define which services should be flushed between requests:
'flush' => [
\App\Services\SomeStatefulService::class,
],Additionally, ensure that any service bindings that hold mutable state are registered as scoped or transient bindings rather than singletons, unless the state is intentionally shared across requests.
What Is Laravel Horizon?
Laravel Horizon provides a dashboard and configuration layer for Redis-powered queues. Where Octane addresses HTTP throughput, Horizon addresses queue throughput—giving teams visibility into job processing rates, failure rates, and worker allocation across multiple queue groups.
Installing and Configuring Horizon
composer require laravel/horizon php artisan horizon:install
Horizon's configuration lives in config/horizon.php. The most impactful configuration block is the environments section, which defines supervisor groups per environment:
'environments' => [
'production' => [
'supervisor-1' => [
'connection' => 'redis',
'queue' => ['critical', 'default', 'low'],
'balance' => 'auto',
'minProcesses' => 1,
'maxProcesses' => 10,
'balanceCooldown' => 3,
'tries' => 3,
'timeout' => 60,
],
],
],The balance setting is particularly valuable for SaaS workloads. Setting it to auto allows Horizon to dynamically allocate workers across queues based on job volume. A spike in critical queue depth—say, a surge in payment webhooks—will automatically draw workers away from lower-priority queues without manual intervention.
Queue Prioritization Strategy
A well-structured queue hierarchy is foundational to reliable SaaS operation. A common pattern used in production Laravel applications separates jobs into three tiers:
- Critical: Payment processing, authentication events, data export completions
- Default: Email delivery, in-app notifications, cache warming
- Low: Report generation, analytics aggregation, bulk data imports
This separation ensures that a flood of low-priority jobs—such as a marketing email campaign—never delays time-sensitive operations.
Combining Octane and Horizon in Production
Running Octane and Horizon together in production requires a process manager to keep both services alive. Supervisor is the standard choice on Linux-based servers.
A minimal Supervisor configuration for both services:
[program:octane] command=php /var/www/artisan octane:start --workers=4 --no-interaction autostart=true autorestart=true user=www-data redirect_stderr=true stdout_logfile=/var/log/octane.log [program:horizon] command=php /var/www/artisan horizon autostart=true autorestart=true user=www-data redirect_stderr=true stdout_logfile=/var/log/horizon.log
When deploying new code, both services must be gracefully restarted to pick up changes:
php artisan octane:reload php artisan horizon:terminate
Including these commands in your deployment pipeline—whether through GitHub Actions, Envoyer, or a custom CI/CD script—ensures that no stale code runs in production after a release.
Measuring the Impact: Profiling and Observability
Deploying Octane and Horizon without instrumentation is flying blind. Two tools complement this stack effectively.
Blackfire provides request-level profiling, revealing exactly where time is spent during a request—database queries, cache lookups, service resolution, and application logic. After an Octane upgrade, profiling a representative set of endpoints will confirm that p95 response times have improved and identify any remaining bottlenecks.
Laravel Telescope offers broader observability across requests, jobs, and cache operations during development and staging. Telescope's job panel is particularly useful when tuning Horizon, as it surfaces slow jobs and exception traces in a readable interface.
For production observability, integrating Horizon's metrics with a monitoring platform—Datadog, Grafana, or similar—enables alerting on queue depth, failed job rates, and worker saturation before they impact end users.
A Practical Scaling Checklist
Before deploying Octane and Horizon to a production SaaS environment, verify the following:
- Stateful singletons are identified and either flushed between requests or converted to scoped bindings
- Queue groups are defined with appropriate priority tiers
- Horizon's balance mode is set to auto for dynamic worker allocation
- Supervisor configurations include auto-restart directives for both services
- Deployment scripts gracefully reload Octane and terminate Horizon
- Blackfire or an equivalent profiler has confirmed p95 response time improvements
- Horizon dashboard access is protected behind authentication middleware
From Performance Gains to Revenue Impact
The connection between application performance and business outcomes is direct and measurable. Faster response times reduce user drop-off. Reliable queue processing means payments process on time, notifications arrive promptly, and data exports complete without user follow-up. These are not abstract technical improvements—they translate into retention, conversion, and revenue.
Scaling a Laravel SaaS application with Octane and Horizon is a well-understood, repeatable process. The tools are mature, the patterns are proven, and the performance gains are significant. What varies is the specific configuration that matches your application's traffic profile, job distribution, and infrastructure constraints.
If your Laravel codebase is approaching the limits of its current architecture—or if you want to get ahead of those limits before they cause incidents—a targeted performance audit is the most efficient starting point. Book a strategy call to review your queue throughput, identify Octane readiness, and map out the steps that will keep your SaaS platform performing at scale.
Related articles
Continue exploring Laravel insights and practical delivery strategies.
How Laravel Octane Cuts Response Times for SaaS Apps
Learn how Laravel Octane eliminates bootstrap overhead, manages persistent worker state, and cuts p95 response times by up to 70% in production SaaS applications.
Florentin Pomirleanu
Principal Laravel Consultant
Build Scalable SaaS Dashboards with Filament & Laravel
FilamentPHP transforms how Laravel teams build SaaS dashboards and admin panels. Instead of maintaining complex custom tooling, developers can leverage Filamentβs resource system, reactive Livewire components, and multi-tenant architecture to deliver production-ready dashboards in a fraction of the time. This guide explores how Filament integrates with Laravel to power scalable SaaS platforms, streamline internal tooling, and support real-time operational data without building everything.
Florentin Pomirleanu
Principal Laravel Consultant
AI-Assisted Laravel Development with OpenAI Codex
Learn how to build Laravel applications faster using OpenAI Codex. This step-by-step guide shows how to generate models, controllers, and views with AI.
Florentin Pomirleanu
Principal Laravel Consultant
Laravel consulting
Need senior Laravel help for this topic?
Let's adapt these practices to your product and deliver the next milestone.