r/PostgreSQL • • 1d ago

Tools Feedback wanted: Airflow style database orchestration written 100% in SQL (just use postgres!)

https://github.com/merlinm/pgflow
8 Upvotes

5 comments sorted by

5

u/Discordbothost 22h ago

Worth load-testing before relying on this for wide fan-out: dblink opens one connection per async call, so hundreds of parallel steps will hit max_connections fast and won't play well behind pgbouncer's transaction pooling. Tested wide fan-out yet?

1

u/merlinm 18h ago edited 18h ago

This would be an alternative to pgbouncer, especially for multi database distributed processing....this is not designed for application traffic obviously, so with orchestrated processing it's possible to bypass pgbouncer since you have your own managed thread pool. max_connections only plays if the orchestrator is delegating to itself, which is not advised for complex distributed environments. outbound connections is only limited by your fd limit and how much overhead you want to pay for on the polling loop. SSL connections are slow, so you definitely want to keep workers higher than active query count if you need to run a large number of concurrent synchronous queries.

The idea is you set the target concurrency to something small (like 8 or how many cpus you allocate to the load).

The number of workers only limits the amount of non async (where pgasync waits for query response) queries you can run at once. If you have to support a lot of remote processing, this has to be raised, or you have to move to async model.

Here is what my workers like in production from cpu standpoint. I turn them on and off like light switches. Of course, you can do that with pgbouncer, but with orchesrtration framework you get that control within broader processing structure.

For large fanouts, the only real bottleneck is the orchestrator itself; it can process >10k tasks in ideal conditions, but with complex flows and other migitating factors (slow performance, lousy cpuspeed shared database), it can be a lot less than that. If your tasks are > 1 second, this tends not to be a major factor unless you are managing a very large number of databases.

1

u/DuckDatum 17h ago

Hey, I’m building an orchestration engine too! I wanted something like Dagster (orchestration with data platform semantics), but as easy to use as duckdb. I went through a wishlist of features in the design process like: ephemeral in nature, resumable on failure, horizontally scalable without networking requirements between workers, and plenty of features to help track data operations and even use data op results as conditions in orchestration logic.

I am using Postgres / SQLite as the backend. SQLite for local, Postgres for “prod.” Also S3 or local disk for other artifacts.

Maybe we could team up? I would like to have experience developing OSS with a team.

1

u/merlinm 16h ago

Absolutely! what's your current state of play?

Based on your summary, I went a little differently, deep postgres; and the orchestrator never receives task/query results(this quickly becomes a bottlneck at high task volumes, albeit with some limits).

1

u/AutoModerator 1d ago

AI Policy:

Linux is not one of those anti-AI projects, and if somebody has issues with that, they can do the open-source thing and fork it. Or just walk away., Linus Torvalds.

Mod decisions will be based on the quality of the content, not who or what generated it.

Sub Resources:

Youtube Channel

Free Postgres Webinars and Workshops

Discord: People, Postgres, Data

Join us, we have cookies and nice people.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.