malak4web/laravel-rust-queue 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

malak4web/laravel-rust-queue

Composer 安装命令:

composer require malak4web/laravel-rust-queue

包简介

A high-performance, low-memory Laravel queue worker runner powered by a Rust daemon.

README 文档

README

A high-performance, low-memory process manager and queue runner for Laravel, powered by a lightweight Rust daemon.

Replace heavy, persistent, long-running PHP worker processes (which consume ~50MB – 200MB+ RAM each 24/7) with a single Rust worker daemon that consumes under 5MB of RAM when idle.

⚡ How it Works

Instead of running standard PHP queue workers that stay booted in memory waiting for jobs, this package runs a pre-compiled Rust daemon:

  1. Lightweight Idle State: The Rust daemon connects to your Redis queue and uses blocking pops (BLPOP) to wait for jobs. Idle memory footprint is under 5MB.
  2. On-Demand PHP Execution: When a job arrives, Rust pops it and spawns php artisan rust-worker:execute as a short-lived process.
  3. Secure stdin Piping: Rust writes the job payload directly to the PHP process via stdin. This avoids shell escaping vulnerabilities and command length limitations.
  4. Immediate Memory Release: Once the job finishes, the PHP process terminates immediately, releasing 100% of its memory back to the OS.
  5. Robust Retries & Failure Logging:
    • Failed jobs are automatically retried by Rust after a 5-second backoff (placed in the Redis delayed set).
    • Once a job exceeds its maximum retries, the final run sets a final flag, triggering Laravel's native event listeners to write it to the failed_jobs table.

📦 Installation

Step 1: Install via Composer

You can install this package in any Laravel project via Composer:

composer require malak4web/laravel-rust-queue

Step 2: Publish Configuration

Publish the package configuration file:

php artisan vendor:publish --provider="Malak\LaravelRustQueue\RustQueueServiceProvider"

This creates config/rust-queue.php in your application.

🚀 Running the Worker

To start the Rust worker daemon:

php artisan rust-worker:start

This Artisan command will automatically detect your operating system and CPU architecture, find the correct pre-compiled binary inside the package's bin/ directory, and launch it.

Production Setup (Supervisor)

In production, run the pre-compiled binary directly or supervise the Artisan command. Here is an example Supervisor configuration:

[program:laravel-rust-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /home/forge/app.com/artisan rust-worker:start
autostart=true
autorestart=true
user=forge
numprocs=1
redirect_stderr=true
stdout_logfile=/home/forge/app.com/storage/logs/rust-worker.log
stopwaitsecs=3600

⚙️ Configuration (config/rust-queue.php)

return [
    // The connection name from config/queue.php to listen to
    'connection' => env('RUST_QUEUE_CONNECTION', 'redis'),

    // The queue name to monitor
    'queue' => env('RUST_QUEUE_NAME', 'default'),

    // Path to the directory containing pre-compiled binaries
    'bin_path' => env('RUST_QUEUE_BIN_PATH', base_path('vendor/malak/laravel-rust-queue/bin')),

    // PHP binary used to run the artisan command
    'php_path' => env('RUST_QUEUE_PHP_PATH', PHP_BINARY),

    // Path to the Laravel artisan script
    'artisan_path' => env('RUST_QUEUE_ARTISAN_PATH', base_path('artisan')),
];

🛠️ Compiling Binaries Manually

The package comes pre-compiled with optimized binaries for Windows, macOS, and Linux in the bin/ directory. If you make modifications to the Rust daemon, you can compile it yourself:

  1. Navigate to the rust/ folder:
    cd packages/laravel-rust-queue/rust
  2. Build the release binary:
    cargo build --release
  3. Locate the compiled executable under target/release/rust-worker and copy it to the package's bin/ folder.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固