All Projects → ph4r05 → Laravel Queue Database Ph4

ph4r05 / Laravel Queue Database Ph4

Licence: mit
Laravel Database Queue with Optimistic locking

Projects that are alternatives of or similar to Laravel Queue Database Ph4

Laravel Couchbase
Couchbase providers for Laravel
Stars: ✭ 31 (-16.22%)
Mutual labels:  database, laravel, queue
Analogue
Analogue ORM : Data Mapper ORM for Laravel/PHP
Stars: ✭ 618 (+1570.27%)
Mutual labels:  database, laravel
Laravel Failed Job Monitor
Get notified when a queued job fails
Stars: ✭ 582 (+1472.97%)
Mutual labels:  laravel, queue
Laravel
Laravel Model Generator
Stars: ✭ 715 (+1832.43%)
Mutual labels:  database, laravel
Performance
⏱ PHP performance tool analyser your script on time, memory usage and db query. Support Laravel and Composer for web, web console and command line interfaces.
Stars: ✭ 429 (+1059.46%)
Mutual labels:  database, laravel
Laravel Backup
A package to backup your Laravel app
Stars: ✭ 4,752 (+12743.24%)
Mutual labels:  database, laravel
Laravel Options
Global key-value store in the database
Stars: ✭ 626 (+1591.89%)
Mutual labels:  database, laravel
Laravel Job Status
Add ability to track Job progress, status and result dispatched to Queue.
Stars: ✭ 279 (+654.05%)
Mutual labels:  laravel, queue
Eloquent Driver
A package that allows you to store Statamic entries in a database.
Stars: ✭ 28 (-24.32%)
Mutual labels:  database, laravel
Larawiz
Larawiz is a easy project scaffolder for Laravel
Stars: ✭ 28 (-24.32%)
Mutual labels:  database, laravel
Gorose
GoRose(go orm), a mini database ORM for golang, which inspired by the famous php framwork laravle's eloquent. It will be friendly for php developer and python or ruby developer. Currently provides six major database drivers: mysql,sqlite3,postgres,oracle,mssql, Clickhouse.
Stars: ✭ 947 (+2459.46%)
Mutual labels:  database, laravel
Lada Cache
A Redis based, fully automated and scalable database cache layer for Laravel
Stars: ✭ 424 (+1045.95%)
Mutual labels:  database, laravel
Closuretable
Adjacency List’ed Closure Table database design pattern implementation for the Laravel framework.
Stars: ✭ 391 (+956.76%)
Mutual labels:  database, laravel
Laravel Eloquent Query Cache
Adding cache on your Laravel Eloquent queries' results is now a breeze.
Stars: ✭ 529 (+1329.73%)
Mutual labels:  database, laravel
Uniquewith Validator
Custom Laravel Validator for combined unique indexes
Stars: ✭ 352 (+851.35%)
Mutual labels:  database, laravel
Laravel Translatable
A Laravel package for multilingual models
Stars: ✭ 624 (+1586.49%)
Mutual labels:  database, laravel
Laravel World
provide countries, states, and cities relations and database.
Stars: ✭ 222 (+500%)
Mutual labels:  database, laravel
Laravel Database Encryption
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
Stars: ✭ 238 (+543.24%)
Mutual labels:  database, laravel
Learning laravel kernel
Laravel核心代码学习
Stars: ✭ 789 (+2032.43%)
Mutual labels:  database, laravel
Laravel Database Logger
Log database query sql in Laravel Application, support Guard,Auth to multiple file record
Stars: ✭ 31 (-16.22%)
Mutual labels:  database, laravel

Database Queue driver for Laravel with optimistic locking

Latest Stable Version Build Status Total Downloads StyleCI License

Laravel database queue implementation using optimistic locking. Increases concurrency, eliminates deadlocks.

Installation

  1. Install this package via composer using:
composer require ph4r05/laravel-queue-database-ph4
  1. Create job table
php artisan queue_ph4:table
php artisan migrate
  1. Queue configuration
<?php
// config/queue.php

return [
    'database_ph4' => [
        'driver' => 'database_ph4',
        'table' => 'jobs_ph4',
        'queue' => 'default',
        'retry_after' => 4,
        'num_workers' => 1,
        'window_strategy' => 1,
    ],
];
  • The num_workers should correspond to the number of workers processing jobs in the queue.
  • window_strategy.
    • 0 means worker selects one available job for processing. Smaller throughput, job ordering is preserved as with pessimistic locking.
    • 1 means workers will select num_workers next available jobs and picks one at random. Higher throughput with slight job reordering (for more info please refer to the blog)

To use the optimistic locking you can now change your .env:

QUEUE_DRIVER=database_ph4

Usage

Once you completed the configuration you can use Laravel Queue API. If you used other queue drivers you do not need to change anything else. If you do not know how to use Queue API, please refer to the official Laravel documentation: http://laravel.com/docs/queues

Testing

Run the tests with:

vendor/bin/phpunit

Blog post about optimistic locking

https://ph4r05.deadcode.me/blog/2017/12/23/laravel-queues-optimization.html

Benefits:

  • No need for explicit transactions. Single query auto-commit transactions are OK.
  • No DB level locking, thus no deadlocks. Works also with databases without deadlock detection (older MySQL).
  • Job executed exactly once (as opposed to pessimistic default DB locking)
  • High throughput.
  • Tested with MySQL, PostgreSQL, Sqlite.

Cons:

  • Job ordering can be slightly shifted with multiple workers (reordering 0-70 in 10 000 jobs)

Contribution

You can contribute to this package by discovering bugs and opening issues. Please, add to which version of package you create pull request or issue.

Donations

Thank you for all your support!

Monero:

87iMuZKqgBZbxjvjJaieTqLBsW3VKtkiuRXL2arcr8eiL4eK8kFi4QbaXCXGgmNWYp5Linpd9pj5McFZ8SQevkenGuZWMCT

Bitcoin:

17hzavLCXqavzmWEEjtX54VeCJVmbrHZQC
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].