GitHunt
VI

virgilhawkins00/fiberflow

πŸš€ Revolutionary Laravel queue package leveraging PHP 8.1+ Fibers for 10-50x throughput improvement. Zero state pollution, async I/O, real-time dashboard.

FiberFlow

Latest Release
GitHub Tests Action Status
PHP Version
Laravel Version
License

FiberFlow is a revolutionary Laravel queue worker that leverages PHP 8.1+ Fibers to enable true cooperative multitasking within a single process. Process 10,000 HTTP requests using only 100MB of RAM by suspending jobs during I/O operations instead of blocking the entire worker.

πŸš€ The Problem

Traditional Laravel queue workers operate sequentially: one job at a time, one process per job. When a job makes an HTTP request that takes 2 seconds to respond, the worker process (consuming 30-50MB of RAM) sits idle, waiting. To scale, you spawn more processes, consuming gigabytes of memory.

FiberFlow changes the game.

✨ The Solution

Using PHP Fibers and the Revolt event loop, FiberFlow allows multiple jobs to run concurrently in a single worker process. When a job waits for I/O (HTTP requests, database queries with async drivers), the Fiber suspends, allowing other jobs to execute. The result:

  • 70% reduction in infrastructure costs for I/O-heavy workloads
  • 10x throughput for webhook processing, API integrations, and web scraping
  • Zero configuration for basic usage - drop-in replacement for queue:work
  • Pure PHP - no Swoole, no RoadRunner, no PECL extensions required

πŸ“‹ Requirements

  • PHP 8.2+ (Fibers introduced in 8.1, but 8.2+ recommended for stability)
  • Laravel 11.x or 12.x
  • Composer 2.0+

πŸ“¦ Installation

Install via Composer:

composer require fiberflow/fiberflow

Publish the configuration file (optional):

php artisan vendor:publish --tag=fiberflow-config

🎯 Quick Start

Replace your standard queue worker command:

# Before
php artisan queue:work

# After
php artisan fiber:work

That's it! Your jobs now run concurrently using Fibers.

πŸ’‘ Usage Example

Standard Job (Fiber-Safe)

use FiberFlow\Concerns\AsyncJob;
use FiberFlow\Facades\AsyncHttp;

class ProcessWebhook implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, AsyncJob;

    public function handle()
    {
        // This suspends the Fiber, freeing the worker for other jobs
        $response = AsyncHttp::post('https://api.stripe.com/v1/charges', [
            'amount' => 2000,
            'currency' => 'usd',
        ]);

        // Execution resumes here when the response arrives
        if ($response->successful()) {
            // Process the response...
        }
    }
}

Configuration

// config/fiberflow.php
return [
    'max_concurrency' => 50,  // Maximum concurrent Fibers
    'memory_limit' => 256,    // MB per worker
    'timeout' => 60,          // Seconds per job
    'dashboard' => true,      // Enable TUI dashboard
];

🎨 TUI Dashboard

Launch the worker with real-time monitoring:

php artisan fiber:work --dashboard

Displays:

  • Active vs. suspended Fibers
  • Memory usage
  • Jobs/second throughput
  • Queue depth

⚠️ Important Considerations

βœ… Ideal Use Cases

  • Webhooks & Notifications: Sending thousands of HTTP requests to third-party APIs
  • Web Scraping: Fetching data from multiple sources simultaneously
  • API Proxying: Acting as an async middleware between services
  • Email Campaigns: Sending bulk emails via external SMTP services
  • CPU-Intensive Tasks: Image/video processing (blocks the event loop)
  • Legacy Database Operations: Heavy Eloquent queries using blocking PDO (use async drivers or defer pattern)
  • File System Operations: Large file reads/writes (blocking I/O)

πŸ”’ Container Isolation

FiberFlow uses Container Sandboxing to prevent state pollution between concurrent jobs. Each Fiber gets its own cloned container instance, ensuring:

  • No shared singletons between jobs
  • Isolated authentication state
  • Safe multi-tenant operations

πŸ“š Documentation

πŸ§ͺ Testing

composer test

Run tests across PHP versions:

composer test:coverage

🀝 Contributing

Please see CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.

πŸ“„ License

FiberFlow is open-sourced software licensed under the MIT license.

πŸ™ Credits


Made with ❀️ for the Laravel community

virgilhawkins00/fiberflow | GitHunt