Download the PHP package atymic/laravel-bulk-sqs-queue without Composer
On this page you can find all versions of the php package atymic/laravel-bulk-sqs-queue. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download atymic/laravel-bulk-sqs-queue
More information about atymic/laravel-bulk-sqs-queue
Files in atymic/laravel-bulk-sqs-queue
Package laravel-bulk-sqs-queue
Short Description Laravel SQS Bulk Queue
License MIT
Homepage https://github.com/atymic/laravel-bulk-sqs-queue
Informations about the package laravel-bulk-sqs-queue
Laravel SQS Bulk Queue
Installation
You can install the package via composer:
How it works
By default, Laravel allows you to easily execute a batch of jobs with Queue::bulk()
method or with built-in job batching. Both methods accept an array of jobs for dispatch and loop over every job, making one HTTP request for each job.
This isn't an issue when you are dispatching a few jobs, but there's two major issues with bigger batches:
- Waiting for 1000 http requests (even SQS, with 20-50ms latency) is two to five seconds, that's slow!
- SQS is billed per request, and they support batching of up to 10 messages for the same cost as a single
sendMessage
call. That's a 10x cost saving!
But AWS SQS has a batch action that let you group up to 10 messages with a single request, in order to reduce costs. Under the hood, this package override the bulk method to:
- Batch jobs into 10 per request, or 200kb chunks (SQS has a maximum of 256kb, including request overhead/etc)
- Dispatch those batches asynchronously, up to
$concurrency
at a time (default 5)
That's about it. With this package, the laravel queue system should work the exact same as normal. You should have the same result in your application and your AWS SQS dashboard but with a smaller AWS bill :)
Usage
This package provides a queue connector called sqs-bulk
. Inside your queue.php
config file, add it to connections
:
Then you can start a queue worker for the new "connection" and the given queue ('default' queue can be override with SQS_QUEUE
):
It will process new jobs as they are pushed onto the queue. You can group jobs with queue's bulk method:
or with laravel's built-in job batching feature:
It should have processed the 3 jobs by creating 3 "messages" on AWS SQS but with only 1 request.
Failing jobs
This package only affect the way jobs are transmitted to AWS SQS. Once received by AWS SQS, they are handled as separate messages. From AWS SQS perspective, there is no relation between messages. The batch request can result in a combination of successful and unsuccessful actions that doesn't affect each others.
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- atymic
- Laravel-BatchSQS
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-bulk-sqs-queue with dependencies
illuminate/contracts Version ^9.0 || ^10.0 || ^11.0
aws/aws-sdk-php Version ^3