Git Product home page Git Product logo

bredis's Introduction

bredis queue driver for Laravel

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

When do you need bredis?

You need bredis when all of these are applied:

  1. You don't want your jobs to be delayed because your workers are currently sleeping.
  2. You don't want to run queue:work --sleep=0 on current Redis queue driver because it will devour your CPU when there is no job.

Hence, you need your workers to idle-wait for a job and process them just when they arrive, with nearly no delay. With bredis you can happily run queue:work --sleep=0 without worrying about busy waiting and CPU overload.

Installation

1. Install the package via compioser

composer require halaei/bredis

2. Add the service provider to your config/app.php

Halaei\BRedis\BlockingRedisServiceProvider::class

3. Add bredis connections to app/queue.php

'bredis' => [
    'driver'      => 'bredis',
    'connection'  => 'default',
    'queue'       => 'default',
    'retry_after' => 90,
    'timeout'     => 10, //Maximum seconds to wait for a job
],

Please note that if you need to increase 'timeout' in the config array above, you should increase 'retry_after' in the array as well as --timeout in your queue:work commands.

Warning: bredis queue workers don't bother handling jobs that are delayed or reserved. So when using bredis workers, you have to have at least one redis worker as well.

Note: bredis queue driver is 100% compatible with redis driver. In other words, you may push the jobs using redis driver and pop them using bredis, or vice versa.

bredis's People

Contributors

halaei avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

bredis's Issues

Delayed jobs

In the README:

Warning: bredis queue workers don't bother handling jobs that are delayed or reserved. So when using bredis workers, you have to have at least one redis worker as well.

Is there a specific reason for this? I'd like the add support for delayed jobs.

Some background: I needed to implement a shim for encrypting job payloads (domain requirement for all data at rest to be encrypted), but I was using bredis, so I decided to basically just copy bredis into my project and modify it to add support for that, because the way to implement encryption is to extend the existing queue driver. I can't really have two queue drivers with separate features... so I just decided to copy yours and make my changes on top of it. This also means that I'd need to have a separate driver which only has my encryption changes without blpop to handle delayed jobs. If there's an easier way to just have this one driver do everything, that'd obviously be better.

Also, would love if you took a look at #2 again! ๐Ÿ˜›

I'd appreciate being pointed in the right direction!

Thanks

Delayed and reserved queues

Hi, first thanks for your project.

About that:

Warning: bredis queue workers don't bother handling jobs that are delayed or reserved. So when using bredis workers, you have to have at least one redis worker as well.

How are we supposed to start a second worker with another driver (redis/bredis)? What is your suggested approach to it?

php artisan queue:work # how we decide which driver to use?

Thanks for your time.
--J

Implement brpoplpush

So I saw you wrote up laravel/framework#23057

I wanted to say thanks for your work in pushing for blocking pops in Laravel, non-blocking is so slow it hurts!

Any chance you'll port the changes from your PR into this lib? I think it would be nice as a shim for people who will be staying on Laravel 5.5 for the forseeable future (since it's LTS). I'm already using bredis for now because I find it pretty much unusably slow with non-blocking.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.