Database Queue

Adds Database queues to Flarum

Compatible with Flarum v1.4.1

Latest release 0.1-beta.2

117 downloads

released on Jul 13, 2021

Tags

This extension allows you to easily run a queue, using your database and by configuring one cron(job).

Disclaimer: this extension is provided "as is" by Blomstra. Only community support is provided.

Background and when you need this

By default, Flarum runs without a (background) queue. This means that all tasks of Flarum are processed during the request of the user.

A great example of this is email sending. When using flarum/subscriptions, fof/follow-tags, ianm/follow-users or any other extension that allows subscribing to things, email sent out to notify users. For smaller communities this is not a big deal, but at some point you'll notice your requests (posting for instance) may start to slow down. All of these emails are dispatched after the post is stored to the database.

To resolve this increasing burden, you can run a Queue. A queue runs on your server, it does not interact with the user and their requests. A user request, however, can dispatch tasks to the queue. This extension provides the easiest implementation of a queue and works on shared hosting environments as well.

Install

composer require blomstra/database-queue:*

Enable the extension inside the admin area and see below how to set up the queue worker.

Set up

Go into your hosting control panel and set up the following task to run every minute:

php flarum queue:work --stop-when-empty

Or in cron language:

* * * * * cd /path/to/flarum && php flarum queue:work --stop-when-empty

FAQ

What is the difference with blomstra/flarum-redis? The redis package (it's officially not an extension) is meant for larger communities. Redis offers the ability to scale the number of workers up however you need. Running a queue worker which pulls jobs from the database can also negatively impact your community performance when processing a lot of notifications and other queue tasks.


  • Blomstra provides managed Flarum hosting.
  • https://blomstra.net

© 2022 Hyn by DaniĆ«l "Luceos" Klabbers. All rights reserved. · Extensions and extension information is provided by the respective (copyright holding) authors. · Extiverse is not affiliated to the Flarum project or Flarum foundation. · Images on Extiverse pages are from Unsplash.