Moved slow work onto a River job queue
Moved slow work off the request path onto a River job queue — 15
worker modules, 8 scheduled tasks and 20 pg_cron jobs — so a request
returns while the work behind it carries on.
2025

Situation. Some work has no business happening while a user waits.
Sending mail, rebuilding a search index, generating a document,
recalculating standings — do any of it inside the request and the
user watches a spinner for something they never asked to see. Do it
in a goroutine instead and it disappears the moment the process
restarts, which it will, mid‑deploy, with no record that it was ever
supposed to happen.

Task. Background work needed somewhere durable to live: a queue that
survives a restart, retries a failure, and can be looked at when
something has not happened.

Action. River was the choice, largely because it keeps its queue in
PostgreSQL — the database is already the system of record, so a job
and the rows it touches commit or roll back together, and there is
no second piece of infrastructure to run and reason about. There are
15 worker modules behind it and 8 scheduled tasks. Underneath, 20
pg_cron jobs handle the maintenance the database is better placed to
do itself: pruning partitions, rotating salts, refreshing
aggregates. Anything slow enough to notice was moved off the request
path and onto one of the two.

Result. Requests return quickly and the slow work still finishes,
with retries and a visible history when it does not. Keeping the
queue in Postgres rather than a dedicated broker is a deliberate
limit: it will not scale forever, and at some volume it becomes the
wrong answer. For a platform whose bottleneck is the database
anyway, one less moving part was worth more than headroom that was
not going to be used.

Categories:
1Backend Engineering	/categories/backend/	data.engineer.company	70
1Databases	/categories/databases/	data.engineer.company	70
1PostgreSQL	/categories/postgresql/	data.engineer.company	70
1Automation & CI/CD	/categories/automation/	data.engineer.company	70
1Reliability & Backups	/categories/reliability/	data.engineer.company	70
1Performance Tuning	/categories/performance/	data.engineer.company	70

Services:
1Backend & API Development	/services/backend-development/	data.engineer.company	70
1AI Agent Tools & MCP Servers	/services/ai-tools/	data.engineer.company	70
1Database Design & Modeling	/services/database-design/	data.engineer.company	70
1Site Reliability & Monitoring	/services/site-reliability/	data.engineer.company	70

hThis page on the web	URL:https://data.engineer.company/portfolio/moved-slow-work-onto-a-river-job-queue/	data.engineer.company	70
