weengsapp/asynq

Run Laravel commands asynchronously

This package's canonical repository appears to be gone and the package has been frozen as a result.

1.0.0 2018-09-30 10:12 UTC

This package is not auto-updated.

Last update: 2019-12-23 19:12:36 UTC


README

CircleCI Software License

Reason of being

We at Weengs were not getting the full benefits of Laravel queues because most of our servers are small EC2 instances with only 1 CPU, which means that even if we configure Supervisor to run more than one process it won't make much of a difference as 1 CPU can only run one process at a time.

But we are in 2018 and there's ReactPHP to help us out. We firmly believe we should't be forced to increase our AWS bills in order to have better queue processing power, that's why we've created Asynq (pronounced async-queue), a little proxy class that makes use of ReactPHP's ChildProcess component and allows us to call any artisan command and execute them asynchronously, dramatically increasing our queue processing power. Before Asynq we had peaks of queued jobs waiting to be processed throughout the day, but not anymore.

Installation

composer require weengsapp/asynq

And register the command in app/Console/Kernel.php:

protected $commands = [
    \Weengs\Asynq::class
];

Usage

Use it as proxy to call any artisan command:

php artisan weengs:asynq 4 queue:work

Where 4 is the number of processes to be run and queue:work is the signature of the command to be called.

All command options will be forwarded to the proxied command:

For example php artisan weengs:asynq 4 queue:work --env=development translates to php artisan queue:work --env=development.

Limitations

For now we don't forward command arguments, only options are forwarded.

How to contribute

Pull requests are welcome :)

License

MIT