News for hackers. Stuff that matters.
Re:River: A fast, robust job queue for Go and Postgres by bgentry on Monday November 20, 2023 @12:26PM (#38351027)
Hi HN, I'm one of the authors of River along with Brandur. We've been working on this library for a few months and thought it was about time we get it out into the world.

Transactional job queues have been a recurring theme throughout my career as a backend and distributed systems engineer at Heroku, Opendoor, and Mux. Despite the problems with non-transactional queues being well understood I keep encountering these same problems. I wrote a bit about them here in our docs: https://riverqueue.com/docs/transactional-enqueueing

Ultimately I want to help engineers be able to focus their time on building a reliable product, not chasing down distributed systems edge cases. I think most people underestimate just how far you can get with this model—most systems will never outgrow the scaling constraints and the rest are generally better off not worrying about these problems until they truly need to.

Please check out the website and docs for more info. We have a lot more coming but first we want to iron out the API design with the community and get some feedback on what features people are most excited for. https://riverqueue.com/

Re:River: A fast, robust job queue for Go and Postgres by tombh on Monday November 20, 2023 @01:44PM (#38352427)
At the bottom of the page on riverqueue.com it appears there's a screenshot of a UI. But I can't seem to find any docs about it. Am I missing something or is it just not available yet?
Re:River: A fast, robust job queue for Go and Postgres by mosen on Monday November 20, 2023 @01:46PM (#38352480)
Looks like it’s underway:

> We're hard at work on more advanced features including a self-hosted web interface. Sign up to get updates on our progress.

Re:River: A fast, robust job queue for Go and Postgres by bgentry on Monday November 20, 2023 @01:50PM (#38352553)
The UI isn't quite ready for outside consumption yet but it is being worked on. I would love to hear more about what you'd like to see in it if you want to share.
Re:River: A fast, robust job queue for Go and Postgres by codegeek on Monday November 20, 2023 @04:08PM (#38354803)
If you could build a UI similar to Hangire [0] or Laravel Horizon [1], that would be awesome.

[0] https://hangfire.io

[1] https://github.com/laravel/horizon

Re:River: A fast, robust job queue for Go and Postgres by fithisux on Monday November 20, 2023 @02:42PM (#38353399)
An Airflow for Gophers?
Re:River: A fast, robust job queue for Go and Postgres by cloverich on Monday November 20, 2023 @01:48PM (#38352512)
So excited y'all created this. Through a few job changes I've been exposed to the most popular background job systems in Rails, Python, JS, etc, and have been shocked at how under appreciated their limitations are relative to what you get out of the box with relational systems. Often I see a lot of DIY add-ons to help close the gaps, but its a lot of work and often still missing tons of edge cases and useful functionality. I always felt going the other way, starting w/ a relational db where many of those needs are free, would make more sense for most start-ups, internal tooling, and smaller scale businesses.

Thank you for this work, I look forward to taking it for a (real) test drive!

Re:River: A fast, robust job queue for Go and Postgres by dangoodmanUT on Monday November 20, 2023 @02:33PM (#38353254)
How do you look at models like temporal.io (service in front of DB) and go-workflows (direct to DB) in comparison? It seems like this is more a step back towards that traditional queue like asynq is, which is where the industry is leaving from to the model of temporal
Re:River: A fast, robust job queue for Go and Postgres by bgentry on Monday November 20, 2023 @03:56PM (#38354598)
I don't think these approaches are necessarily mutually exclusive. There are some great things that can be layered on top of the foundation we've built, including workflows. The best part about doing this is that you can maintain full transactionality within a single primary data store and not introduce another 3rd party or external service into your availability equation.
Re:River: A fast, robust job queue for Go and Postgres by ramchip on Monday November 20, 2023 @07:32PM (#38357102)
Personally I've found Temporal very limited as a queue: no FIFO ordering (!), no priorities, no routing, etc. It's also very complex when you just want async jobs, and more specialized than a DB or message broker, which can be used for many other things. I think there's a place for both.
Re:River: A fast, robust job queue for Go and Postgres by endorphine on Monday November 20, 2023 @02:37PM (#38353327)
How does this compare to https://github.com/vgarvardt/gue?
Re:River: A fast, robust job queue for Go and Postgres by csarva on Monday November 20, 2023 @03:15PM (#38353965)
Not familiar with either project, but it seems gue is a fork of the authors previous project, https://github.com/bgentry/que-go
Re:River: A fast, robust job queue for Go and Postgres by bgentry on Monday November 20, 2023 @03:59PM (#38354647)
Yes, there's a note in the readme to that effect although I don't think they bear much resemblance anymore. que-go was an experiment I hacked up on a plane ride 9 years ago and thought was worth sharing. I was never happy with its technical design: holding a transaction for the duration of a job severely limits available use cases and worsens bloat issues. It was also never something I intended to continue developing alongside my other priorities at the time and I should have made that clearer in the project's readme from the start.
Re:River: A fast, robust job queue for Go and Postgres by gregwebs on Monday November 20, 2023 @03:09PM (#38353851)
Re:River: A fast, robust job queue for Go and Postgres by radicalbyte on Monday November 20, 2023 @03:25PM (#38354126)
I don't know why people even use libraries in those languages - assuming you stick to a database engine you understand well then the (main)-database-as-queue pattern is trivial to implement. Any time spent writing code is quickly won back by not having to debug weird edge cases, and sometimes you can highly optimize what you're doing (for example it becomes easy to migrate jobs which are data-dominated to the DB server which can cut processing time by 2-3 orders of magnitude).

It's particularly suited to use cases such background jobs, workflows or other operations which occur within your application and scales well enough for what 99.9999% of us will be doing.

Re:River: A fast, robust job queue for Go and Postgres by AtlasBarfed on Tuesday November 21, 2023 @06:45PM (#38372302)
I thought the first rule of queues was never use a database as a queue.
Re:River: A fast, robust job queue for Go and Postgres by 22c on Tuesday November 21, 2023 @08:30PM (#38373391)
The "problem" is that a database as a queue doesn't infinitely scale, but nothing infinitely scales. If you're starting to reach the limits of Postgres-as-a-queue then you've either done something very wrong or very right to get to that point.

It's probably more correct to say that the engineering effort required to make a Postgres-as-a-queue scale horizontally is a lot more than the engineering effort required to make a dedicated queueing service scale horizontally. The trade-off is that you're typically going to have to start scaling horizontally much sooner with your dedicated queuing service than with a Postgres database.

The argument for Postgres-as-a-queue is that you might be able to get to market much quicker, which can be significantly more important than how well you can scale down the track.

Re:River: A fast, robust job queue for Go and Postgres by AtlasBarfed on Wednesday November 22, 2023 @09:19AM (#38379492)
I thought Kafka could relatively infinitely scale
Re:River: A fast, robust job queue for Go and Postgres by 22c on Wednesday November 22, 2023 @11:45AM (#38381592)
I wouldn't categorise Kafka as a database.
Re:River: A fast, robust job queue for Go and Postgres by linux2647 on Monday November 20, 2023 @04:45PM (#38355327)
Is there a minimum version of Postgres needed to use this? I’m having trouble finding that information in the docs
Re:River: A fast, robust job queue for Go and Postgres by justinclift on Monday November 20, 2023 @11:45PM (#38359374)
Does it do job completion notification?

Along the lines of:

    _, err := river.Execute(context.Background(), j) // Enqueue the job, and wait for completion
    if err != nil {
        log.Fatalf("Unable to execute job: %s", err)
    }
    log.Printf("Job completed")
Does that make sense?
Re:River: A fast, robust job queue for Go and Postgres by bgentry on Tuesday November 21, 2023 @10:45AM (#38365203)
It sounds like you're looking to be able to find out when a job has finished working, no matter which node it was run on. No, River does not have a mechanism for that today. It's definitely something we've talked about though.
Re:River: A fast, robust job queue for Go and Postgres by justinclift on Tuesday November 21, 2023 @12:25PM (#38366824)
Thanks. Yeah, that's definitely a requirement of the queueing systems I'm working with.

It's effectively "run this remote function, and return when you have the result data".

Fan-out RPC (-ish) style stuff, rather than async "queue an email for sending later".

Re:River: A fast, robust job queue for Go and Postgres by TheProTip on Tuesday November 21, 2023 @12:56AM (#38359918)
Really cool. I'm working on .Net project that I've also adopted a "single dependency" stance on; that being Postgres. I'm pretty thrilled to see I'm not the only one lol!

I plan to use Orleans to handle a lot of the heavy HA/scale lifting. It can likely stand in for Redis in a lot of cache use cases(in some non-obvious ways), and am anticipating writing a Postgres stream provider for it when the time comes.. Will likely end up writing a Postres job queue as well so will definitely check out River for inspiration.

A lot of postgres drivers, including the .Net defacto Npgsql, support logical decode these days which unlocks a ton of exciting use cases and patterns via log processing.