Que
r2dbc-postgresql
Our great sponsors
Que | r2dbc-postgresql | |
---|---|---|
10 | 4 | |
2,282 | 982 | |
0.4% | 0.6% | |
6.0 | 7.5 | |
17 days ago | 12 days ago | |
Ruby | Java | |
MIT License | Apache License 2.0 |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
Que
-
Choose Postgres Queue Technology
> Can you define "low throughput"?
<1000 messages per minute
Not saying SKIP LOCKED can't work with that many. But you'll probably want to do something better.
FWIW, Que uses advisory locks [1]
Few things.
1. The main downside to using PostgreSQL as a pub/sub bus with LISTEN/NOTIFY is that LISTEN is a session feature, making it incompatible with statement level connection pooling.
2. If you are going to do this use advisory locks [0]. Other forms of explicit locking put more pressure on the database while advisory locks are deliberately very lightweight.
My favorite example implementation is que [1] which is ported to several languages.
[0] https://www.postgresql.org/docs/current/explicit-locking.htm...
-
Introducing tobox: a transactional outbox framework
Probably worth mentioning that aside from delayed_job there are at least two more modern alternatives backed by the DB: Que and good_job.
-
Sidekiq jobs in ActiveRecord transactions
Good article. Sidekiq is a good, well respected too. However if you are starting out I would recommend not using it, and instead choosing a DB based queue system. We have great success with que, but there are others like good_job.
-
SQL Maxis: Why We Ditched RabbitMQ and Replaced It with a Postgres Queue
(not sure why this comment was dead, I vouched for it)
There are a lot of ways to implement a queue in an RDBMS and a lot of those ways are naive to locking behavior. That said, with PostgreSQL specifically, there are some techniques that result in an efficient queue without locking problems. The article doesn't really talk about their implementation so we can't know what they did, but one open source example is Que[1]. Que uses a combination of advisory locking rather than row-level locks and notification channels to great effect, as you can read in the README.
-
Delayed Job vs. Sidekiq: Which Is Better?
https://github.com/que-rb/que
This one seems to be the most performant. By a lot too, from my understanding (haven't ran any benchmark myself, but the readme shows some good postgres knowledge)
-
Sidekiq VS Que - a user suggested alternative
2 projects | 3 Feb 2022
Que seems like a good alternative if one doesn't want to use Reids. However, given that most apps need Redis (and have it within their infrastructure) nowadays, I still think that Sidekiq is the better option in the generic case.
-
Devious SQL: Message Queuing Using Native PostgreSQL
Implementations that use advisory locks like https://github.com/que-rb/que are much more efficient (atleast when I last tested) and will easily reach 10k job/s on even very modest hardware.
There is a Go port of Que but you can also easily port it to any language you like. I have a currently non-OSS implementation in Rust that I might OSS someday when I have time to clean it up.
-
Postgres is a great pub/sub and job server
It’s also possible to use advisory locks to implement a job queue in Postgres. See e.g. Que[1]. Note there are a fair number of corner cases, so studying Que is wise if trying to implement something like this, as well as some (a bit older) elaboration[2].
We implemented a similar design to Que for a specific use case in our application that has a known low volume of jobs and for a variety of reasons benefits from this design over other solutions.
-
Ruby Schedulers: Whenever vs Sidekiq Cron vs Sidekiq Scheduler
Do also take into consideration que-scheduler (disclaimer, am author). It is built on top of the robust que async job system.
r2dbc-postgresql
-
Reactive Backend Applications with Spring Boot, Kotlin and Coroutines (Part 1)
Now that we have an application, let's turn it into a reactive application. For this, we will replace Spring Web dependency with Spring WebFlux, Spring Data JPA with Spring Data R2DBC. We will also add R2DBC dependency for our H2 database. R2DBC works with a reactive driver so it will integrate nicely with the rest of our application to allow us database access in a non-blocking way.
-
I need to create an API, but I don't know what framework to use. What would you choose, of you were me, and scalability is a quite important factor?
However, if you really expect a lot of users (especially concurrent ones) to use your API, you should delve into the world of reactive programming. Use tools like RxJS (JS/TS) or Project Reactor (Java) in such a case, preferably in combination with a broker like Kafka or RabbitMQ. R2DBC is also great for a data store. Then of course if you want to go one step further, there also exists the less popular but very interesting Actor model which Akka easily has ported into Java.
- Postgres is a great pub/sub and job server
What are some alternatives?
Sidekiq - Simple, efficient background processing for Ruby
good_job - Multithreaded, Postgres-based, Active Job backend for Ruby on Rails.
Delayed::Job - Database based asynchronous priority queue system -- Extracted from Shopify
Resque - Resque is a Redis-backed Ruby library for creating background jobs, placing them on multiple queues, and processing them later.
Karafka - Ruby and Rails efficient Kafka processing framework
Shoryuken - A super efficient Amazon SQS thread based message processor for Ruby
RocketJob - Ruby's missing background and batch processing system
Sucker Punch - Sucker Punch is a Ruby asynchronous processing library using concurrent-ruby, heavily influenced by Sidekiq and girl_friday.
March Hare - Idiomatic, fast and well-maintained JRuby client for RabbitMQ
Bunny - Bunny is a popular, easy to use, mature Ruby client for RabbitMQ
Lowkiq - Ordered background jobs processing
Laboristo - Simple messages and workers for AWS SQS