insitro / redun

Yet another redundant workflow engine
https://insitro.github.io/redun/
Apache License 2.0
510 stars 43 forks source link

PostgreSQL Queue Executor (Distributed executor without Amazon/k8s) #78

Open gabriel-v opened 1 year ago

gabriel-v commented 1 year ago

This project is great - but there's no simple way to distribute work on self-hosted hardware, only Amazon this and Amazon that. There are executors that run Docker and K8s, but I'm working in an environment where that is managed elsewhere.

Then, I remembered this article / ad about postgres work queues.

The article above is missing a small detail about waiting for new work - we can use postgres's LISTEN and NOTIFY to have the workers wait with select.select(conn) instead of continuously polling for new changes.

Code:

But the scheduler doesn't just want to execute code - it also wants results back! That's why I used a second queue table to return the results.

Some things of interest you might want me to change:

I want to clean these experiments and submit a PR with the new executor. Before that happens, I think I need to clean some things up:

After this is cleaned up and merged, I think there will be some more discussion points on this:

Let me know what you think, and if you'd want to merge this work

gabriel-v commented 12 months ago

got CI execution here: https://github.com/gabriel-v/redun/actions/runs/6113659282/job/16593587764?pr=3

no new tests so far

PR https://github.com/insitro/redun/pull/84