Keeping a Postgres Queue Healthy
planetscale.com
Keeping a Postgres Queue Healthy
1–10 of 34 posts
Re: Keeping a Postgres Queue Healthy
#2Re: Keeping a Postgres Queue Healthy
#3Re: Keeping a Postgres Queue Healthy
#4It would be nice if this ad at least explained a little bit of the technical side of the solution.
0: https://dev.mysql.com/doc/refman/8.4/en/innodb-performance-t...
Re: Keeping a Postgres Queue Healthy
#5Yo! Author here, I’ll be around if anyone’s got questions!
Re: Keeping a Postgres Queue Healthy
#6Re: Keeping a Postgres Queue Healthy
#7Yo! Author here, I’ll be around if anyone’s got questions!
Did you test with fillfactor < 100 on the queue table? With HOT updates, status changes can reuse dead space without creating new index entries, which seems like it could significantly delay the onset of the death spiral?
Re: Keeping a Postgres Queue Healthy
#81) It seems these two statements conflict with each other:
> The oldest such transaction sets the cutoff—referred to as the "MVCC horizon." Until that transaction completes, every dead tuple newer than its snapshot is retained.
and
> For example, imagine three analytics queries, each running for 40 seconds, staggered 20 seconds apart. No individual query would trigger a timeout for running too long. But because one is always active, the horizon never advances, and the effect on vacuum is the same as one transaction that never ends.
If the three analytics *transactions* (it's transactions that matter, not queries, although there is some subtlety around deferred transactions not acquiring a snapshot until the first query) are started at different times, they will have staggered snapshots and so once the first completes, this should allow the vacuum to advance.
2) Although the problem about this query:
SELECT * FROM jobs
WHERE status = 'pending'
ORDER BY run_at
LIMIT 1
FOR UPDATE SKIP LOCKED;
having to consider dead tuples is a genuine concern and performance problem,
this can also be mitigated by adding a monotonically increasing column
and adding a `WHERE column There is a little subtlety around how you guarantee that the column is monotonically
increasing, given concurrent writers, but the answer to that depends on what tricks
you can fit into your application.3) I almost want to say that the one-line summary is 'Don't combine (very) long-running transactions with (very) high transaction rates in Postgres'
(Is this a fair representation?)
Re: Keeping a Postgres Queue Healthy
#9Postgres can do so much. I see people choose Kafka and SQS for things that Graphile Worker could do all day long.
It’s basically always the bottleneck/problem source in a lot of systems.
Re: Keeping a Postgres Queue Healthy
#10Postgres can do so much. I see people choose Kafka and SQS for things that Graphile Worker could do all day long.
“Use Postgres for everything” is a great philosophy at low/medium scale to keep things simple, but there comes a scaling point where I want my SQL database doing as little possible. It’s basically always the bottleneck/problem source in a lot of systems.